Mercurial > hg-old > index.cgi
changeset 98:81fc353d4d69
Cleaned up old lwasm_expr_result() function and unused EXPR_* flags
author | lost |
---|---|
date | Sat, 17 Jan 2009 07:12:05 +0000 |
parents | 2e8dda44027c |
children | 3dcb12a6f4ff |
files | src/insn_gen.c src/insn_rel.c src/lwasm.c src/lwasm.h |
diffstat | 4 files changed, 4 insertions(+), 84 deletions(-) [+] |
line wrap: on
line diff
--- a/src/insn_gen.c Sat Jan 17 07:09:15 2009 +0000 +++ b/src/insn_gen.c Sat Jan 17 07:12:05 2009 +0000 @@ -140,7 +140,7 @@ { lwasm_emitop(as, l, instab[opnum].ops[3]); (*p)++; - r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST | EXPR_BYTE, &rval, 0); + r = lwasm_expr_result2(as, l, p, 0, &rval, 0); if (r != 0) rval = 0; if (r == 1 && as -> passnum == 2) @@ -212,7 +212,7 @@ lwasm_emitop(as, l, instab[opnum].ops[0]); (*p)++; - r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST | EXPR_BYTE, &rval, 0); + r = lwasm_expr_result2(as, l, p, 0, &rval, 0); if (r != 0) rval = 0; if (r == 1 && as -> passnum == 2)
--- a/src/insn_rel.c Sat Jan 17 07:09:15 2009 +0000 +++ b/src/insn_rel.c Sat Jan 17 07:12:05 2009 +0000 @@ -38,7 +38,7 @@ lwasm_emitop(as, l, instab[opnum].ops[0]); - if ((r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST | EXPR_NOINTERSECT, &v, 0)) < 0) + if ((r = lwasm_expr_result2(as, l, p, 0, &v, 0)) < 0) v = 0; else { @@ -81,7 +81,7 @@ lwasm_emitop(as, l, instab[opnum].ops[0]); - r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST, &v, 0); + r = lwasm_expr_result2(as, l, p, 0, &v, 0); if (r < 0) v = 0; else
--- a/src/lwasm.c Sat Jan 17 07:09:15 2009 +0000 +++ b/src/lwasm.c Sat Jan 17 07:12:05 2009 +0000 @@ -315,82 +315,6 @@ Evaluate an expression according to the flag value. Return 0 if a constant result was obtained, 1 if an incomplete result was obtained, and -1 if an error was flagged. -Symbol resolution will be modified for the object target as follows: -- a symbol which is not defined within a section will evaluate as a constant -- a symbol which is defined within the same section will evaluate as a constant -- a symbol defined in another section will remain unresolved -- external references will also remain unresolved - -EXPR_PASS2PASS will cause the result from pass 1 along with the offset to -the end of the expression to be stored in the line data. There can only be -one such expression per source line. In this case, the expression is parsed -and evaluated on pass 1 but the intermediate representation is re-evaluated -on pass 2. -*/ -/* -int lwasm_expr_result(asmstate_t *as, lwasm_line_t *l, char **inp, int flag, int *val) -{ - lwasm_expr_stack_t *s; - const char *ep; - int rval; - - s = lwasm_evaluate_expr(as, l, *inp, &ep); - if (!s) - { - register_error(as, l, 1, "Bad expression"); - *val = 0; - return -1; - } - *inp = (char *)ep; - - if (flag & EXPR_PASS1CONST && as -> passnum == 1 && !lwasm_expr_result_ckconst(as, s)) - { - register_error(as, l, 1, "Undefined reference (pass 1)"); - *val = 0; - lwasm_expr_stack_free(s); - return -1; - } - if (flag & EXPR_PASS2CONST && as -> passnum == 2 && !lwasm_expr_result_ckconst(as, s)) - { - register_error(as, l, 2, "Undefined reference (pass 2)"); - *val = 0; - lwasm_expr_stack_free(s); - return -1; - } - if (flag & EXPR_NOINTERSECT && !lwasm_expr_is_constant(s)) - { - register_error(as, l, 2, "Invalid inter-section reference"); - } - *val = lwasm_expr_get_value(s); - if (l -> expr) - { - lwasm_expr_stack_free(l -> expr); - l -> expr = NULL; - } - if (lwasm_is_constant(s)) - { - // fully resolved value here - lwasm_expr_stack_free(s); - } - else - { - // incomplete reference here - l -> expr = s; - } - - if (flag & EXPR_BYTE && as -> passnum == 2 && (*val < -128 || *val > 255)) - { - register_error(as, l, 2, "Byte overflow"); - *val &= 0xff; - return -1; - } - if (flag & EXPR_BYTE) - { - *val &= 0xff; - } - - return 0; -} */ int lwasm_expr_result2(asmstate_t *as, lwasm_line_t *l, char **inp, int flag, int *val, int slot) {
--- a/src/lwasm.h Sat Jan 17 07:09:15 2009 +0000 +++ b/src/lwasm.h Sat Jan 17 07:12:05 2009 +0000 @@ -206,10 +206,6 @@ // return 0 on ok, -1 on error, 1 if a complex expression was returned #define EXPR_NOFLAG 0 #define EXPR_PASS1CONST 1 // no forward references on pass 1 -#define EXPR_PASS2CONST 2 // no undefined references on pass 2 -#define EXPR_BYTE 4 // the result must fit within 8 bits -#define EXPR_COMPLEX 8 // a non-constant result is permitted (stored in l -> expr) -#define EXPR_NOINTERSECT 16 // only allow intra-section values (pass 2) __lwasm_E__ int lwasm_expr_result(asmstate_t *as, lwasm_line_t *l, char **inp, int flag, int *val); __lwasm_E__ int lwasm_expr_result2(asmstate_t *as, lwasm_line_t *l, char **inp, int flag, int *val, int slot);