compiler, runtime: Evaluate Expressions in Expression Statements
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -105,8 +105,13 @@ extension ConditionalStatement: EvaluatableStatement {
|
||||
|
||||
extension ExpressionStatement: EvaluatableStatement {
|
||||
public func evaluate(execution: ProgramExecution) -> (ControlFlow, ProgramExecution) {
|
||||
// TODO: Should this do something? Side effects?
|
||||
return (ControlFlow.Next, execution)
|
||||
|
||||
// Evaluate, there might be side effects!
|
||||
return switch self.expression.evaluate(execution: execution) {
|
||||
case (.Ok(_), let updated_context): (ControlFlow.Next, updated_context)
|
||||
case (.Error(let e), let updated_context):
|
||||
(ControlFlow.Next, updated_context.setError(error: e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user