From 1f2b288b32b61dca84fa39eb048e30fbee1262aa Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 13 Feb 2024 23:12:20 -0500 Subject: Slightly more concise generated code for ints --- compile.c | 2 +- nextlang.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compile.c b/compile.c index 414d9871..d48a296a 100644 --- a/compile.c +++ b/compile.c @@ -34,7 +34,7 @@ CORD compile(env_t *env, ast_t *ast) case Nil: return CORD_asprintf("(%r)NULL", compile_type(env, Match(ast, Nil)->type)); case Bool: return Match(ast, Bool)->b ? "yes" : "no"; case Var: return Match(ast, Var)->name; - case Int: return CORD_asprintf("((Int%ld_t)%ld)", Match(ast, Int)->precision, Match(ast, Int)->i); + case Int: return CORD_asprintf("I%ld(%ld)", Match(ast, Int)->precision, Match(ast, Int)->i); case Num: return CORD_asprintf(Match(ast, Num)->precision == 64 ? "%g" : "%gf", Match(ast, Num)->n); case UnaryOp: { auto unop = Match(ast, UnaryOp); diff --git a/nextlang.h b/nextlang.h index d434b3b3..db72661a 100644 --- a/nextlang.h +++ b/nextlang.h @@ -18,6 +18,10 @@ #define Int16_t int16_t #define Int8_t int8_t #define Int_t int64_t +#define I64(x) ((int64_t)x) +#define I32(x) ((int32_t)x) +#define I16(x) ((int16_t)x) +#define I8(x) ((int8_t)x) #define Num64_t double #define Num32_t float -- cgit v1.2.3