diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-13 03:05:56 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-13 03:05:56 -0400 |
| commit | 6f33b9301416d28ef1825358af58c0213ce7567f (patch) | |
| tree | 9cefd844fd2ac2cff754f3d9e0904fd7cd655909 | |
| parent | 2c4f6536a34cb55a5dcaf73908b7ea056da802a9 (diff) | |
Fix min/max
| -rw-r--r-- | compile.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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"); |
