Support Function Calls

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-09 23:16:27 -04:00
parent 708f65a0a9
commit d39127ac17
21 changed files with 984 additions and 311 deletions
+16
View File
@@ -299,3 +299,19 @@ extension ParserAssignmentStatement: CompilableStatement {
))
}
}
extension ReturnStatement: CompilableStatement {
public static func Compile(
node: SwiftTreeSitter.Node, withContext context: CompilerContext
) -> Common.Result<(any Common.EvaluatableStatement, CompilerContext)> {
#RequireNodeType<Node, (EvaluatableStatement, CompilerContext)>(
node: node, type: "return_statement", nice_type_name: "return statement")
let expression_node = node.child(at: 1)!
return switch Expression.Compile(node: expression_node, withContext: context) {
case .Ok(let result): .Ok((ReturnStatement(result), context))
case .Error(let e): .Error(e)
}
}
}