summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-02-02 22:30:34 -0500
committerTavian Barnes <tavianator@gmail.com>2010-02-02 22:30:34 -0500
commit0ede6bd34a27a01fe61ef8221ed38c8525c89e03 (patch)
tree6da8e4175b08f0c4f43fb2e445f671c887ae95a6
parentc07038c627a5601bf331b5c755b9fcce02249fe3 (diff)
downloaddimension-0ede6bd34a27a01fe61ef8221ed38c8525c89e03.tar.xz
Use dmnsn_new_ast_integer() in parsers.
-rw-r--r--dimension/common.rules9
-rw-r--r--dimension/directives.rules8
-rw-r--r--dimension/parse.c4
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: