Mercurial > hg-old > index.cgi
diff src/symbol.c @ 64:aaddd47219b4
Added the 'set' directive
author | lost |
---|---|
date | Mon, 05 Jan 2009 01:27:08 +0000 |
parents | d85ba47b1e8f |
children | 92eb93bffa28 |
line wrap: on
line diff
--- a/src/symbol.c Mon Jan 05 01:17:23 2009 +0000 +++ b/src/symbol.c Mon Jan 05 01:27:08 2009 +0000 @@ -34,7 +34,7 @@ recognize because the expression evaluator must avoid all ambiguity in order to achieve predictable results. The checks here are simply a fuzz check. */ -int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val) +int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val, int flags) { lwasm_symbol_ent_t *se, *se2; char *p; @@ -70,16 +70,24 @@ scontext = as -> context; } - debug_message(3, "lwasm_register_symbol(): registering '%s' (%d) at %04X", sym, scontext, val); + debug_message(3, "lwasm_register_symbol(): registering '%s' (%d) at %04X; flags=%d", sym, scontext, val, flags); // now look it for to see if it is a duplicate se = lwasm_find_symbol(as, sym, scontext); if (se) { - register_error(as, l, 1, "Mulitply defined symbol: %s", sym); - return -1; + if (!(flags & SYMBOL_SET) || (flags & SYMBOL_SET && !(se -> flags & SYMBOL_SET))) + { + register_error(as, l, 1, "Mulitply defined symbol: %s", sym); + return -1; + } } - + if (se) + { + se -> value = val; + return; + } + // if not a duplicate, register it with the value se = lwasm_alloc(sizeof(lwasm_symbol_ent_t)); if (as -> symhead) @@ -99,6 +107,7 @@ se -> value = val; se -> sym = lwasm_strdup(sym); se -> context = scontext; + se -> flags = flags; return 0; }