diff options
author | Camil Staps | 2018-04-03 21:14:37 +0200 |
---|---|---|
committer | Camil Staps | 2018-04-03 21:14:37 +0200 |
commit | b3f9bcbc307e3e8d455ccf560a61dc5129174728 (patch) | |
tree | c1a036d82a25452d8ade3ae29310a699aa809ddd /interpreter/eval.c | |
parent | Resolve #11: print end result as soon as it is in HNF (diff) |
Store integers without pointers
Diffstat (limited to 'interpreter/eval.c')
-rw-r--r-- | interpreter/eval.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/interpreter/eval.c b/interpreter/eval.c index b86c32f..cfcdb0c 100644 --- a/interpreter/eval.c +++ b/interpreter/eval.c @@ -103,7 +103,7 @@ bool match_expr(struct fuspel *rules, struct expression *expr, struct node **nod switch (expr->kind) { case EXPR_INT: - return *((int*) (*node)->var1) == *((int*) expr->var1); + return (*node)->var1 == expr->var1; case EXPR_NAME: push_repl(_repls, (char*) expr->var1, *node); @@ -349,7 +349,7 @@ void print_eval(FILE *out, struct fuspel *rules, struct node **node) { switch ((*node)->kind) { case NODE_INT: - fprintf(out, "%d", *(int*)(*node)->var1); + fprintf(out, "%ld", (INT)(*node)->var1); break; case NODE_NAME: fprintf(out, "%s", (char*)(*node)->var1); @@ -373,6 +373,7 @@ void print_eval(FILE *out, struct fuspel *rules, struct node **node) { eval(rules, &tl, true); print_eval(out, rules, (struct node**) &tl->var1); tl = (struct node*) tl->var2; + eval(rules, &tl, true); } } fprintf(out, "]"); |