diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-24 17:31:14 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-24 17:31:14 -0400 |
| commit | 9b16e1c06cad326b79e3aab8a95d5f97ea07af90 (patch) | |
| tree | 550621f67e985b2e3706ac3c5a68b903dad04849 /src/compile.c | |
| parent | 559d7f24cf5d3a129fdf7b6cc7c75ecb6ca5a8c5 (diff) | |
Move int code to its file
Diffstat (limited to 'src/compile.c')
| -rw-r--r-- | src/compile.c | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/compile.c b/src/compile.c index 12717b98..4aba2008 100644 --- a/src/compile.c +++ b/src/compile.c @@ -23,7 +23,6 @@ #include "compile/types.h" #include "config.h" #include "environment.h" -#include "stdlib/integers.h" #include "stdlib/tables.h" #include "stdlib/text.h" #include "stdlib/util.h" @@ -95,20 +94,7 @@ Text_t compile(env_t *env, ast_t *ast) { // return Texts("_$", Match(ast, Var)->name); code_err(ast, "I don't know of any variable by this name"); } - case Int: { - const char *str = Match(ast, Int)->str; - OptionalInt_t int_val = Int$from_str(str); - if (int_val.small == 0) code_err(ast, "Failed to parse this integer"); - mpz_t i; - mpz_init_set_int(i, int_val); - if (mpz_cmpabs_ui(i, BIGGEST_SMALL_INT) <= 0) { - return Texts("I_small(", str, ")"); - } else if (mpz_cmp_si(i, INT64_MAX) <= 0 && mpz_cmp_si(i, INT64_MIN) >= 0) { - return Texts("Int$from_int64(", str, ")"); - } else { - return Texts("Int$from_str(\"", str, "\")"); - } - } + case Int: return compile_int(ast); case Num: { return Text$from_str(String(hex_double(Match(ast, Num)->n))); } |
