function arguments are getting added to the AST!

This commit is contained in:
SpookyDervish
2025-10-15 07:16:15 +11:00
parent 049db7c53a
commit 3c24b50a80
8 changed files with 123 additions and 25 deletions

View File

@@ -6,18 +6,37 @@
"type": "FunctionStatement",
"name": {
"type": "IdentifierLiteral",
"value": "test"
"value": "add"
},
"return_type": "Int",
"parameters": [],
"parameters": [
{
"type": "FunctionParameter",
"name": "a",
"value_type": "Int"
},
{
"type": "FunctionParameter",
"name": "b",
"value_type": "Int"
}
],
"body": {
"type": "BlockStatement",
"statements": [
{
"type": "ReturnStatement",
"return_value": {
"type": "IntegerLiteral",
"value": 123
"type": "InfixExpression",
"left_node": {
"type": "IdentifierLiteral",
"value": "a"
},
"operator": "+",
"right_node": {
"type": "IdentifierLiteral",
"value": "b"
}
}
}
]
@@ -42,9 +61,18 @@
"type": "CallExpression",
"function": {
"type": "IdentifierLiteral",
"value": "test"
"value": "add"
},
"arguments": []
"arguments": [
{
"type": "IntegerLiteral",
"value": 2
},
{
"type": "IntegerLiteral",
"value": 3
}
]
}
}
]

View File

@@ -7,11 +7,8 @@ target datalayout = ""
define i32 @"test"()
{
test_entry:
%".2" = alloca i32
store i32 3, i32* %".2"
%".4" = load i32, i32* %".2"
%".5" = add i32 %".4", 2
ret i32 %".5"
%".2" = add i32 77, 33
ret i32 %".2"
}
define i32 @"main"()