commit b122311a62711c6b94802af4f578a176f8075463
parent a92383960d0d3e3c3b88d0dc1e323038dce387a8
Author: citbl <citbl@citbl.org>
Date: Sun, 16 Nov 2025 19:51:14 +1000
handle all comparison types
Diffstat:
4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/.zed/debug.json b/.zed/debug.json
@@ -11,7 +11,7 @@
"cwd": "$ZED_WORKTREE_ROOT"
},
"program": "$ZED_WORKTREE_ROOT/oxc",
- "args": ["$ZED_WORKTREE_ROOT/tests/ex-return-empty.ox"],
+ "args": ["$ZED_WORKTREE_ROOT/tests/ex-if-no-parens.ox"],
"request": "launch",
"adapter": "CodeLLDB"
}
diff --git a/TODO b/TODO
@@ -6,7 +6,7 @@
[x] handle for loop with `i = i + 1` and `i += 1` (see ex-for-simple2 and TODO NODE_BINARY_EXPR)
[x] printing `-5` crashes, I think parsing is wrong for `-`, sees as value 5
[x] print allow more than 1 arg
-[/] handle return values
+[x] handle return values
[ ] print allow format
[x] print anything else than a string
[x] call another function from main, that prints something,
diff --git a/src/gen/gen.c b/src/gen/gen.c
@@ -801,9 +801,21 @@ build_if_statement(Gen* gen, Node* node)
case OP_INEQUALITY:
cmp = GCC_JIT_COMPARISON_NE;
break;
+ case OP_GT:
+ cmp = GCC_JIT_COMPARISON_GT;
+ break;
+ case OP_GT_EQ:
+ cmp = GCC_JIT_COMPARISON_GE;
+ break;
+ case OP_LT_EQ:
+ cmp = GCC_JIT_COMPARISON_LE;
+ break;
+ case OP_LT:
+ cmp = GCC_JIT_COMPARISON_LT;
+ break;
default:
- printf("build_statement NODE_IF unhandled, %d\n", op);
- cmp = GCC_JIT_COMPARISON_EQ;
+ printf("/!\\ build_statement NODE_IF unhandled, %d\n", op);
+ cmp = GCC_JIT_COMPARISON_NE;
}
gcc_jit_rvalue* lhs_val = handle_expr(gen, lhs);
diff --git a/tests/ex-if-no-parens.ox b/tests/ex-if-no-parens.ox
@@ -0,0 +1,11 @@
+void main() {
+
+ int i = 5;
+
+ if (i > 5) { print("oops1"); } else { print("start"); }
+ if (i < 5) print("oops1");
+ print("okay");
+ if (i == 5) {print("this should work");}
+ if (i == 5) print("yay");
+ print("huh? no yay?");
+}