compiler: Clean Up Warnings In Compiler
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -81,8 +81,6 @@ extension FunctionDeclaration: Compilable {
|
||||
nice_type_name: "Function Declaration")
|
||||
|
||||
var walker = Walker(node: function_declaration_node)
|
||||
var context = context
|
||||
|
||||
var current_node: Node? = .none
|
||||
|
||||
#MustOr(
|
||||
@@ -224,16 +222,14 @@ extension P4Struct: Compilable {
|
||||
}
|
||||
|
||||
var parse_errs: (any Errorable)? = .none
|
||||
var current_context = context
|
||||
var parsed_fields: [P4StructFieldIdentifier] = Array()
|
||||
|
||||
if currentNode!.nodeType == "struct_declaration_fields" {
|
||||
currentNode!.enumerateNamedChildren { declaration_field in
|
||||
switch VariableDeclarationStatement.Compile(
|
||||
node: declaration_field, withContext: current_context)
|
||||
node: declaration_field, withContext: context)
|
||||
{
|
||||
case .Ok(let declaration):
|
||||
let variable_declaration = declaration as! VariableDeclarationStatement
|
||||
case .Ok(let variable_declaration):
|
||||
parsed_fields.append(
|
||||
P4StructFieldIdentifier(
|
||||
id: variable_declaration.identifier, withType: variable_declaration.initializer.type()
|
||||
@@ -507,7 +503,7 @@ extension Control: Compilable {
|
||||
else {
|
||||
return .Error(maybe_apply_statement.error()!)
|
||||
}
|
||||
apply = (apply_statement as! ApplyStatement)
|
||||
apply = apply_statement
|
||||
|
||||
// The apply is the last thing in a control declaration.
|
||||
// But, that is handled by the compiler.
|
||||
@@ -570,7 +566,6 @@ extension Action: Compilable {
|
||||
|
||||
var walker = Walker(node: node)
|
||||
var current_node: Node? = .none
|
||||
var current_context = context
|
||||
|
||||
// Skip action keyword
|
||||
walker.next()
|
||||
@@ -585,7 +580,7 @@ extension Action: Compilable {
|
||||
|
||||
guard
|
||||
case .Ok(let action_name) = Identifier.Compile(
|
||||
node: current_node!, withContext: current_context)
|
||||
node: current_node!, withContext: context)
|
||||
else {
|
||||
return Result.Error(
|
||||
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(
|
||||
node: current_node!, withContext: current_context)
|
||||
node: current_node!, withContext: context)
|
||||
guard case .Ok(let action_parameters) = maybe_action_parameters
|
||||
else {
|
||||
return .Error(maybe_action_parameters.error()!)
|
||||
@@ -645,7 +640,7 @@ extension Action: Compilable {
|
||||
return .Ok(
|
||||
Action(
|
||||
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
|
||||
|
||||
let current_context = context
|
||||
|
||||
#MustOr(
|
||||
result: current_node, thing: walker.getNext(),
|
||||
or: Result<TableKeyEntry>.Error(
|
||||
@@ -672,7 +665,7 @@ extension TableKeyEntry: Compilable {
|
||||
withError: "Missing table key entry declaration component")))
|
||||
|
||||
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 {
|
||||
return Result.Error(maybe_keyset_expression.error()!)
|
||||
}
|
||||
@@ -688,7 +681,7 @@ extension TableKeyEntry: Compilable {
|
||||
withError: "Missing table key entry declaration component")))
|
||||
|
||||
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 {
|
||||
return .Error(maybe_match_type.error()!)
|
||||
}
|
||||
@@ -829,21 +822,19 @@ extension TablePropertyList: Compilable {
|
||||
#RequireNodeType<Node, TablePropertyList>(
|
||||
node: node, type: "table_property_list", nice_type_name: "Table Property List")
|
||||
|
||||
var current_context = context
|
||||
|
||||
var keys: [TableKeys] = Array()
|
||||
var actions: [TableActionsProperty] = Array()
|
||||
var errors: [any Errorable] = Array()
|
||||
|
||||
node.enumerateNamedChildren { child in
|
||||
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):
|
||||
keys.append(table_key)
|
||||
case .Error(let e): errors.append(e)
|
||||
}
|
||||
} 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):
|
||||
actions.append(table_action_property)
|
||||
case .Error(let e): errors.append(e)
|
||||
@@ -906,8 +897,6 @@ extension Table: Compilable {
|
||||
|
||||
var current_node: Node? = .none
|
||||
|
||||
let current_context = context
|
||||
|
||||
walker.next() // Skip the XXX?
|
||||
#MustOr(
|
||||
result: current_node, thing: walker.getNext(),
|
||||
@@ -918,7 +907,7 @@ extension Table: Compilable {
|
||||
|
||||
guard
|
||||
case .Ok(let table_name) = Identifier.Compile(
|
||||
node: current_node!, withContext: current_context)
|
||||
node: current_node!, withContext: context)
|
||||
else {
|
||||
return Result.Error(
|
||||
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(
|
||||
node: current_node!, withContext: current_context)
|
||||
node: current_node!, withContext: context)
|
||||
guard case .Ok(let table_property_list) = maybe_table_property_list else {
|
||||
return Result.Error(maybe_table_property_list.error()!)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user