compiler: Clean Up Warnings In Compiler
Continuous Integration / Grammar Tests (push) Successful in 37s
Continuous Integration / Library Format Tests (push) Successful in 1m47s
Continuous Integration / Library Tests (push) Successful in 4m51s

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-05-29 17:47:05 -04:00
parent 6882a32858
commit 6908d9a91d
+12 -23
View File
@@ -81,8 +81,6 @@ extension FunctionDeclaration: Compilable {
nice_type_name: "Function Declaration") nice_type_name: "Function Declaration")
var walker = Walker(node: function_declaration_node) var walker = Walker(node: function_declaration_node)
var context = context
var current_node: Node? = .none var current_node: Node? = .none
#MustOr( #MustOr(
@@ -224,16 +222,14 @@ extension P4Struct: Compilable {
} }
var parse_errs: (any Errorable)? = .none var parse_errs: (any Errorable)? = .none
var current_context = context
var parsed_fields: [P4StructFieldIdentifier] = Array() var parsed_fields: [P4StructFieldIdentifier] = Array()
if currentNode!.nodeType == "struct_declaration_fields" { if currentNode!.nodeType == "struct_declaration_fields" {
currentNode!.enumerateNamedChildren { declaration_field in currentNode!.enumerateNamedChildren { declaration_field in
switch VariableDeclarationStatement.Compile( switch VariableDeclarationStatement.Compile(
node: declaration_field, withContext: current_context) node: declaration_field, withContext: context)
{ {
case .Ok(let declaration): case .Ok(let variable_declaration):
let variable_declaration = declaration as! VariableDeclarationStatement
parsed_fields.append( parsed_fields.append(
P4StructFieldIdentifier( P4StructFieldIdentifier(
id: variable_declaration.identifier, withType: variable_declaration.initializer.type() id: variable_declaration.identifier, withType: variable_declaration.initializer.type()
@@ -507,7 +503,7 @@ extension Control: Compilable {
else { else {
return .Error(maybe_apply_statement.error()!) return .Error(maybe_apply_statement.error()!)
} }
apply = (apply_statement as! ApplyStatement) apply = apply_statement
// The apply is the last thing in a control declaration. // The apply is the last thing in a control declaration.
// But, that is handled by the compiler. // But, that is handled by the compiler.
@@ -570,7 +566,6 @@ extension Action: Compilable {
var walker = Walker(node: node) var walker = Walker(node: node)
var current_node: Node? = .none var current_node: Node? = .none
var current_context = context
// Skip action keyword // Skip action keyword
walker.next() walker.next()
@@ -585,7 +580,7 @@ extension Action: Compilable {
guard guard
case .Ok(let action_name) = Identifier.Compile( case .Ok(let action_name) = Identifier.Compile(
node: current_node!, withContext: current_context) node: current_node!, withContext: context)
else { else {
return Result.Error( return Result.Error(
Error(withMessage: "Could not parse an action name from \(current_node!.text!)")) Error(withMessage: "Could not parse an action name from \(current_node!.text!)"))
@@ -601,7 +596,7 @@ extension Action: Compilable {
) )
let maybe_action_parameters = ParameterList.Compile( let maybe_action_parameters = ParameterList.Compile(
node: current_node!, withContext: current_context) node: current_node!, withContext: context)
guard case .Ok(let action_parameters) = maybe_action_parameters guard case .Ok(let action_parameters) = maybe_action_parameters
else { else {
return .Error(maybe_action_parameters.error()!) return .Error(maybe_action_parameters.error()!)
@@ -645,7 +640,7 @@ extension Action: Compilable {
return .Ok( return .Ok(
Action( Action(
named: action_name, withParameters: action_parameters, named: action_name, withParameters: action_parameters,
withBody: (action_body as! BlockStatement))) withBody: action_body))
} }
} }
@@ -662,8 +657,6 @@ extension TableKeyEntry: Compilable {
var current_node: Node? = .none var current_node: Node? = .none
let current_context = context
#MustOr( #MustOr(
result: current_node, thing: walker.getNext(), result: current_node, thing: walker.getNext(),
or: Result<TableKeyEntry>.Error( or: Result<TableKeyEntry>.Error(
@@ -672,7 +665,7 @@ extension TableKeyEntry: Compilable {
withError: "Missing table key entry declaration component"))) withError: "Missing table key entry declaration component")))
let maybe_keyset_expression = KeysetExpression.compile( let maybe_keyset_expression = KeysetExpression.compile(
node: current_node!, withContext: current_context) node: current_node!, withContext: context)
guard case .Ok(let keyset_expression) = maybe_keyset_expression else { guard case .Ok(let keyset_expression) = maybe_keyset_expression else {
return Result.Error(maybe_keyset_expression.error()!) return Result.Error(maybe_keyset_expression.error()!)
} }
@@ -688,7 +681,7 @@ extension TableKeyEntry: Compilable {
withError: "Missing table key entry declaration component"))) withError: "Missing table key entry declaration component")))
let maybe_match_type = TableKeyMatchType.Compile( let maybe_match_type = TableKeyMatchType.Compile(
node: current_node!, withContext: current_context) node: current_node!, withContext: context)
guard case .Ok(let match_type) = maybe_match_type else { guard case .Ok(let match_type) = maybe_match_type else {
return .Error(maybe_match_type.error()!) return .Error(maybe_match_type.error()!)
} }
@@ -829,21 +822,19 @@ extension TablePropertyList: Compilable {
#RequireNodeType<Node, TablePropertyList>( #RequireNodeType<Node, TablePropertyList>(
node: node, type: "table_property_list", nice_type_name: "Table Property List") node: node, type: "table_property_list", nice_type_name: "Table Property List")
var current_context = context
var keys: [TableKeys] = Array() var keys: [TableKeys] = Array()
var actions: [TableActionsProperty] = Array() var actions: [TableActionsProperty] = Array()
var errors: [any Errorable] = Array() var errors: [any Errorable] = Array()
node.enumerateNamedChildren { child in node.enumerateNamedChildren { child in
if child.nodeType == "table_keys" { if child.nodeType == "table_keys" {
switch TableKeys.Compile(node: child, withContext: current_context) { switch TableKeys.Compile(node: child, withContext: context) {
case .Ok(let table_key): case .Ok(let table_key):
keys.append(table_key) keys.append(table_key)
case .Error(let e): errors.append(e) case .Error(let e): errors.append(e)
} }
} else if child.nodeType == "table_actions" { } else if child.nodeType == "table_actions" {
switch TableActionsProperty.Compile(node: child, withContext: current_context) { switch TableActionsProperty.Compile(node: child, withContext: context) {
case .Ok(let table_action_property): case .Ok(let table_action_property):
actions.append(table_action_property) actions.append(table_action_property)
case .Error(let e): errors.append(e) case .Error(let e): errors.append(e)
@@ -906,8 +897,6 @@ extension Table: Compilable {
var current_node: Node? = .none var current_node: Node? = .none
let current_context = context
walker.next() // Skip the XXX? walker.next() // Skip the XXX?
#MustOr( #MustOr(
result: current_node, thing: walker.getNext(), result: current_node, thing: walker.getNext(),
@@ -918,7 +907,7 @@ extension Table: Compilable {
guard guard
case .Ok(let table_name) = Identifier.Compile( case .Ok(let table_name) = Identifier.Compile(
node: current_node!, withContext: current_context) node: current_node!, withContext: context)
else { else {
return Result.Error( return Result.Error(
Error(withMessage: "Could not parse a table name from \(current_node!.text!)")) Error(withMessage: "Could not parse a table name from \(current_node!.text!)"))
@@ -935,7 +924,7 @@ extension Table: Compilable {
)) ))
let maybe_table_property_list = TablePropertyList.Compile( let maybe_table_property_list = TablePropertyList.Compile(
node: current_node!, withContext: current_context) node: current_node!, withContext: context)
guard case .Ok(let table_property_list) = maybe_table_property_list else { guard case .Ok(let table_property_list) = maybe_table_property_list else {
return Result.Error(maybe_table_property_list.error()!) return Result.Error(maybe_table_property_list.error()!)
} }