Make Formatter Happy

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-09 23:17:18 -04:00
parent d39127ac17
commit ad7e5a6f6d
11 changed files with 53 additions and 38 deletions
+1 -1
View File
@@ -16,4 +16,4 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import Common
import P4Lang
import P4Lang
+7 -4
View File
@@ -400,18 +400,21 @@ extension FunctionCall: EvaluatableExpression {
guard case .Ok(let argument_value) = maybe_argument_value else {
return .Error(Error(withMessage: "Cannot evaluate argument \(arg_idx): \(argument)"))
}
called_execution = called_execution.declare(identifier: parameter.name, withValue: argument_value)
called_execution = called_execution.declare(
identifier: parameter.name, withValue: argument_value)
}
let (control_flow, _) = body.evaluate(execution: called_execution)
return switch control_flow {
case ControlFlow.Return(let value): if let value = value {
.Ok(value)
case ControlFlow.Return(let value):
if let value = value {
.Ok(value)
} else {
.Error(Error(withMessage: "No value returned from called function (\(self.callee.name))"))
}
default: .Error(Error(withMessage: "No value returned from called function (\(self.callee.name))"))
default:
.Error(Error(withMessage: "No value returned from called function (\(self.callee.name))"))
}
}
+16 -6
View File
@@ -45,9 +45,14 @@ extension ParserStateDirectTransition: EvaluatableParserState {
for statement in statements {
let (control_flow, next_program) = statement.evaluate(execution: program)
switch control_flow {
case .Next: program = next_program // Ok!
case .Error: return (reject, next_program)
default: return (reject, next_program.setError(error: Error(withMessage: "Invalid control flow (\(control_flow) in parser)")))
case .Next: program = next_program // Ok!
case .Error: return (reject, next_program)
default:
return (
reject,
next_program.setError(
error: Error(withMessage: "Invalid control flow (\(control_flow) in parser)"))
)
}
}
let res = program.scopes.lookup(identifier: get_next_state())
@@ -100,9 +105,14 @@ extension ParserStateSelectTransition: EvaluatableParserState {
for statement in statements {
let (control_flow, next_program) = statement.evaluate(execution: program)
switch control_flow {
case .Next: program = next_program // Ok!
case .Error: return (reject, next_program)
default: return (reject, next_program.setError(error: Error(withMessage: "Invalid control flow (\(control_flow) in parser)")))
case .Next: program = next_program // Ok!
case .Error: return (reject, next_program)
default:
return (
reject,
next_program.setError(
error: Error(withMessage: "Invalid control flow (\(control_flow) in parser)"))
)
}
}
+2 -4
View File
@@ -108,10 +108,8 @@ extension ExpressionStatement: EvaluatableStatement {
extension ReturnStatement: EvaluatableStatement {
public func evaluate(execution: ProgramExecution) -> (ControlFlow, ProgramExecution) {
return switch self.value.evaluate(execution: execution) {
case .Ok(let v): (ControlFlow.Return(v), execution)
case .Error(let e): (ControlFlow.Error, execution.setError(error: e))
case .Ok(let v): (ControlFlow.Return(v), execution)
case .Error(let e): (ControlFlow.Error, execution.setError(error: e))
}
}
}