if statements work
This commit is contained in:
@@ -21,26 +21,57 @@
|
||||
},
|
||||
"value": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 0
|
||||
"value": 123
|
||||
},
|
||||
"value_type": "Int"
|
||||
},
|
||||
{
|
||||
"type": "ReassignStatement",
|
||||
"ident": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "x"
|
||||
},
|
||||
"right_value": {
|
||||
"type": "InfixExpression",
|
||||
"left_node": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "x"
|
||||
"type": "ExpressionStatement",
|
||||
"expr": {
|
||||
"type": "IfStatement",
|
||||
"condition": {
|
||||
"type": "InfixExpression",
|
||||
"left_node": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "x"
|
||||
},
|
||||
"operator": "==",
|
||||
"right_node": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 123
|
||||
}
|
||||
},
|
||||
"operator": "*",
|
||||
"right_node": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 2
|
||||
"consequence": {
|
||||
"type": "BlockStatement",
|
||||
"statements": [
|
||||
{
|
||||
"type": "ReassignStatement",
|
||||
"ident": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "x"
|
||||
},
|
||||
"right_value": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"alternative": {
|
||||
"type": "BlockStatement",
|
||||
"statements": [
|
||||
{
|
||||
"type": "ReassignStatement",
|
||||
"ident": {
|
||||
"type": "IdentifierLiteral",
|
||||
"value": "x"
|
||||
},
|
||||
"right_value": {
|
||||
"type": "IntegerLiteral",
|
||||
"value": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
23
debug/ir.ll
23
debug/ir.ll
@@ -2,14 +2,23 @@
|
||||
target triple = "x86_64-pc-windows-msvc"
|
||||
target datalayout = ""
|
||||
|
||||
define i32 @"test"()
|
||||
{
|
||||
test_entry:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
@"true" = constant i1 1
|
||||
@"false" = constant i1 0
|
||||
define i32 @"main"()
|
||||
{
|
||||
main_entry:
|
||||
ret i32 123
|
||||
%".2" = alloca i32
|
||||
store i32 6, i32* %".2"
|
||||
%".4" = load i32, i32* %".2"
|
||||
%".5" = icmp eq i32 %".4", 5
|
||||
br i1 %".5", label %"main_entry.if", label %"main_entry.else"
|
||||
main_entry.if:
|
||||
store i32 0, i32* %".2"
|
||||
br label %"main_entry.endif"
|
||||
main_entry.else:
|
||||
store i32 1, i32* %".2"
|
||||
br label %"main_entry.endif"
|
||||
main_entry.endif:
|
||||
%".11" = load i32, i32* %".2"
|
||||
ret i32 %".11"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user