compiler, runtime: Control Declarations Have Apply Statements
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -329,3 +329,19 @@ extension ReturnStatement: CompilableStatement {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ApplyStatement: CompilableStatement {
|
||||
public static func Compile(
|
||||
node: SwiftTreeSitter.Node, withContext context: CompilerContext
|
||||
) -> Common.Result<(any Common.EvaluatableStatement, CompilerContext)> {
|
||||
#RequireNodeType<Node, (EvaluatableStatement, CompilerContext)>(
|
||||
node: node, type: "apply_statement", nice_type_name: "apply statement")
|
||||
|
||||
let expression_node = node.child(at: 1)!
|
||||
|
||||
return switch BlockStatement.Compile(node: expression_node, withContext: context) {
|
||||
case .Ok((let statement, let updated_context)): .Ok((ApplyStatement(statement as! BlockStatement), updated_context))
|
||||
case .Error(let e): .Error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user