From d08f795794b33a5d52e39c6b9f0c4e6e88fede3d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 13 Aug 2024 01:30:25 -0400 Subject: Partially working first draft of bigints --- repl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'repl.c') diff --git a/repl.c b/repl.c index 7d4eae33..9b92146f 100644 --- a/repl.c +++ b/repl.c @@ -344,10 +344,11 @@ void eval(env_t *env, ast_t *ast, void *dest) case Int: { if (!dest) return; switch (Match(ast, Int)->bits) { - case 0: case 64: *(int64_t*)dest = Match(ast, Int)->i; break; - case 32: *(int32_t*)dest = Match(ast, Int)->i; break; - case 16: *(int16_t*)dest = Match(ast, Int)->i; break; - case 8: *(int8_t*)dest = Match(ast, Int)->i; break; + case 0: *(Int_t*)dest = Int$from_text(Match(ast, Int)->str); break; + case 64: *(int64_t*)dest = Int64$from_text(Match(ast, Int)->str, NULL); break; + case 32: *(int32_t*)dest = Int32$from_text(Match(ast, Int)->str, NULL); break; + case 16: *(int16_t*)dest = Int16$from_text(Match(ast, Int)->str, NULL); break; + case 8: *(int8_t*)dest = Int8$from_text(Match(ast, Int)->str, NULL); break; default: errx(1, "Invalid int bits: %ld", Match(ast, Int)->bits); } break; @@ -484,7 +485,7 @@ void eval(env_t *env, ast_t *ast, void *dest) char item_buf[item_size] = {}; for (ast_list_t *item = Match(ast, Array)->items; item; item = item->next) { eval(env, item->ast, item_buf); - Array$insert(&arr, item_buf, 0, padded_type_size(Match(t, ArrayType)->item_type)); + Array$insert(&arr, item_buf, I(0), padded_type_size(Match(t, ArrayType)->item_type)); } memcpy(dest, &arr, sizeof(array_t)); break; -- cgit v1.2.3