aboutsummaryrefslogtreecommitdiff
path: root/repl.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-13 01:30:25 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-13 01:30:25 -0400
commitd08f795794b33a5d52e39c6b9f0c4e6e88fede3d (patch)
tree7267e0828b73685f9af0c3e9cf58212c45af289c /repl.c
parentc1c889b024529ac754f83caec4cc15971123d07b (diff)
Partially working first draft of bigints
Diffstat (limited to 'repl.c')
-rw-r--r--repl.c11
1 files changed, 6 insertions, 5 deletions
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;