aboutsummaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 80e9578..df53561 100644
--- a/eval.c
+++ b/eval.c
@@ -1,3 +1,4 @@
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "util.h"
@@ -12,6 +13,7 @@ struct expression *
eval(struct expression *expr)
{
struct expression *l, *r, *c;
+ struct declaration *d;
int op;
switch (expr->kind) {
@@ -21,6 +23,13 @@ eval(struct expression *expr)
expr->kind = EXPRCONST;
expr->constant.i = intconstvalue(expr->ident.decl->value);
break;
+ case EXPRCOMPOUND:
+ d = mkdecl(DECLOBJECT, expr->type, LINKNONE);
+ d->value = mkglobal(NULL, true);
+ emitdata(d, expr->compound.init);
+ expr->kind = EXPRIDENT;
+ expr->ident.decl = d;
+ break;
case EXPRUNARY:
l = eval(expr->unary.base);
if (expr->unary.op != TBAND)