aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-13 11:35:22 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-13 11:35:22 -0400
commit1ce826b9c3e9e57fe3acbd2abb5252bdeb630963 (patch)
tree7827cd14bca9d30f703804feb3da38fee560ad90
parent2c79bf2d7183f69405bc7f5fbaf4a5fc95c98d8a (diff)
Tweak to codegen for range iteration
-rw-r--r--compile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 333c54fe..8c7dc6df 100644
--- a/compile.c
+++ b/compile.c
@@ -852,7 +852,7 @@ CORD compile_statement(env_t *env, ast_t *ast)
"const Range_t range = ", range, ";\n"
"if (range.step.small == 0) fail(\"This range has a 'step' of zero and will loop infinitely!\");\n"
"bool negative = (Int$compare_value(range.step, I(0)) < 0);\n"
- "for (Int_t ", value, " = range.first; negative ? Int$compare_value(", value, ", range.last) >= 0 : Int$compare_value(", value, ", range.last) <= 0 ; ", value, " = Int$plus(", value, ", range.step)) {\n"
+ "for (Int_t ", value, " = range.first; ({ int32_t cmp = Int$compare_value(", value, ", range.last); negative ? cmp >= 0 : cmp <= 0;}) ; ", value, " = Int$plus(", value, ", range.step)) {\n"
"\t", body,
"\n}",
stop,