diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-26 14:58:51 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-26 14:58:51 -0400 |
| commit | cb1d36c6d8bc84f3422c71ab3eb29606e80f7837 (patch) | |
| tree | 0c4c56effdcf258e9807f8d0257d6e445598b70f /src/compile/comparisons.c | |
| parent | d25d5642392f93623d1eb4d11156d293fe6df546 (diff) | |
Formatting for reductions
Diffstat (limited to 'src/compile/comparisons.c')
| -rw-r--r-- | src/compile/comparisons.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/compile/comparisons.c b/src/compile/comparisons.c index d73664de..d7531261 100644 --- a/src/compile/comparisons.c +++ b/src/compile/comparisons.c @@ -7,6 +7,18 @@ #include "../typecheck.h" #include "compilation.h" +static CONSTFUNC const char *comparison_operator(ast_e tag) { + switch (tag) { + case Equals: return "=="; + case NotEquals: return "!="; + case LessThan: return "<"; + case LessThanOrEquals: return "<="; + case GreaterThan: return ">"; + case GreaterThanOrEquals: return ">="; + default: return NULL; + } +} + Text_t compile_comparison(env_t *env, ast_t *ast) { switch (ast->tag) { @@ -75,7 +87,7 @@ Text_t compile_comparison(env_t *env, ast_t *ast) { if (ast->tag == Compare) return Texts("generic_compare(stack(", lhs, "), stack(", rhs, "), ", compile_type_info(operand_t), ")"); - const char *op = binop_operator(ast->tag); + const char *op = comparison_operator(ast->tag); switch (operand_t->tag) { case BigIntType: return Texts("(Int$compare_value(", lhs, ", ", rhs, ") ", op, " 0)"); case BoolType: |
