diff options
Diffstat (limited to 'dimension')
-rw-r--r-- | dimension/common.rules | 9 | ||||
-rw-r--r-- | dimension/directives.rules | 8 | ||||
-rw-r--r-- | dimension/parse.c | 4 |
3 files changed, 5 insertions, 16 deletions
diff --git a/dimension/common.rules b/dimension/common.rules index ef4b3dd..2725925 100644 --- a/dimension/common.rules +++ b/dimension/common.rules @@ -437,14 +437,7 @@ COLOR_KEYWORD_GROUP: COLOR_KEYWORD_GROUP_INIT COLOR_KEYWORD_ITEM ; COLOR_KEYWORD_GROUP_INIT: /* empty */ { - dmnsn_astnode zero = - dmnsn_new_astnode(DMNSN_AST_INTEGER, @$); - zero.ptr = malloc(sizeof(long)); - if (!zero.ptr) - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Failed to allocate room for integer."); - *(long *)zero.ptr = 0; - + dmnsn_astnode zero = dmnsn_new_ast_integer(0); $$ = dmnsn_eval_vector(zero, symtable); dmnsn_delete_astnode(zero); } diff --git a/dimension/directives.rules b/dimension/directives.rules index db47bb9..5bbd813 100644 --- a/dimension/directives.rules +++ b/dimension/directives.rules @@ -48,13 +48,7 @@ RVALUE: ARITH_EXPR ";" %dprec 2 { CONDITIONAL: ARITH_EXPR { /* Force the expression to be evaluated logically */ - dmnsn_astnode zero = dmnsn_new_astnode(DMNSN_AST_INTEGER, @$); - zero.ptr = malloc(sizeof(long)); - if (!zero.ptr) - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Failed to allocate room for integer."); - *(long *)zero.ptr = 0; - + dmnsn_astnode zero = dmnsn_new_ast_integer(0); $$ = dmnsn_new_astnode2(DMNSN_AST_OR, @$, zero, $1); } | ARITH_EXPR "=" ARITH_EXPR { diff --git a/dimension/parse.c b/dimension/parse.c index 6ff5628..bd40ff8 100644 --- a/dimension/parse.c +++ b/dimension/parse.c @@ -791,7 +791,9 @@ dmnsn_eval(dmnsn_astnode astnode, dmnsn_symbol_table *symtable) case DMNSN_AST_NONE: case DMNSN_AST_INTEGER: case DMNSN_AST_FLOAT: - ++*astnode.refcount; + do { + ++*astnode.refcount; + } while (*astnode.refcount <= 1); return astnode; case DMNSN_AST_VECTOR: |