Mercurial > hg-old > index.cgi
diff src/lwasm.c @ 79:d0ce3f5f6797
Checkpointing deployment of non-constant expression handling
author | lost |
---|---|
date | Sat, 10 Jan 2009 07:09:14 +0000 |
parents | 121bf4a588ea |
children | e12edcfbebd5 |
line wrap: on
line diff
--- a/src/lwasm.c Sat Jan 10 05:00:42 2009 +0000 +++ b/src/lwasm.c Sat Jan 10 07:09:14 2009 +0000 @@ -384,14 +384,15 @@ */ int lwasm_expr_result2(asmstate_t *as, lwasm_line_t *l, char **inp, int flag, int *val, int slot) { - lwasm_expr_stack_t *s; + lwasm_expr_stack_t *s = NULL; const char *ep; int rval; - if (as -> passnum == 1) + if (as -> passnum == 1 || slot < 0) { s = lwasm_evaluate_expr(as, l, *inp, &ep); - l -> exprs[slot] = s; + if (slot >= 0) + l -> exprs[slot] = s; if (!s) { register_error(as, l, 1, "Bad expression"); @@ -399,8 +400,11 @@ return -1; } *inp = (char *)ep; - l -> exprends[slot] = *inp; - l -> exprvals[slot] = lwasm_expr_get_value(s); + if (slot >= 0) + { + l -> exprends[slot] = *inp; + l -> exprvals[slot] = lwasm_expr_get_value(s); + } } else if (l -> exprs[slot]) { @@ -417,21 +421,28 @@ s = NULL; } - if (!s) + if (!s && slot >= 0) { *val = l -> exprvals[slot]; return 0; } + else if (!s) + { + *val = 0; + return 0; + } // was a constant result on pass 1 requested? // that means we must have a constant on either pass if (flag & EXPR_PASS1CONST) { *val = 0; - l -> exprvals[slot] = 0; + if (slot >= 0) + l -> exprvals[slot] = 0; register_error(as, l, 1, "Illegal forward, external, or inter-section reference"); lwasm_expr_stack_free(s); - l -> exprs[slot] = NULL; + if (slot >= 0) + l -> exprs[slot] = NULL; return -1; }