aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-13 03:05:56 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-13 03:05:56 -0400
commit6f33b9301416d28ef1825358af58c0213ce7567f (patch)
tree9cefd844fd2ac2cff754f3d9e0904fd7cd655909 /compile.c
parent2c4f6536a34cb55a5dcaf73908b7ea056da802a9 (diff)
Fix min/max
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 77157d43..b020a458 100644
--- a/compile.c
+++ b/compile.c
@@ -1776,7 +1776,9 @@ CORD compile(env_t *env, ast_t *ast)
type_t *key_t = get_type(expr_env, key);
CORD comparison;
- if (key_t->tag == IntType || key_t->tag == NumType || key_t->tag == BoolType || key_t->tag == PointerType)
+ if (key_t->tag == IntType && Match(key_t, IntType)->bits == 0)
+ comparison = CORD_all("(Int$compare_value(", lhs_key, ", ", rhs_key, ")", (ast->tag == Min ? "<=" : ">="), "0)");
+ else if (key_t->tag == IntType || key_t->tag == NumType || key_t->tag == BoolType || key_t->tag == PointerType)
comparison = CORD_all("((", lhs_key, ")", (ast->tag == Min ? "<=" : ">="), "(", rhs_key, "))");
else if (key_t->tag == TextType)
comparison = CORD_all("CORD_cmp(", lhs_key, ", ", rhs_key, ")", (ast->tag == Min ? "<=" : ">="), "0");