Mercurial > hg-old > index.cgi
diff src/parse.c @ 57:035b95a3690f
Added conditional assembly and macros
author | lost |
---|---|
date | Mon, 05 Jan 2009 00:01:21 +0000 |
parents | b9856da2674a |
children | d85ba47b1e8f |
line wrap: on
line diff
--- a/src/parse.c Sun Jan 04 21:43:05 2009 +0000 +++ b/src/parse.c Mon Jan 05 00:01:21 2009 +0000 @@ -43,7 +43,8 @@ if (!*p) { - as -> context += 1; + if (as -> inmacro == 0) + as -> context = lwasm_next_context(as); return 0; } @@ -81,7 +82,8 @@ p++; if (!*p) { - as -> context += 1; + if (as -> inmacro == 0) + as -> context = lwasm_next_context(as); return 0; } } @@ -112,8 +114,6 @@ while (*p2 && isspace(*p2)) p2++; - // check for macro (pass 1) - // look up instruction in insn table for (opnum = 0; instab[opnum].opcode; opnum++) { @@ -121,7 +121,18 @@ break; } - if (!(instab[opnum].opcode) || !(instab[opnum].fn)) + if (as -> inmacro && instab[opnum].endm == 0) + { + add_macro_line(as, l -> text); + } + + if (as -> inmacro == 0 && as -> skipcond == 0) + { + if (expand_macro(as, l, &p2, opc) == 0) + goto done_line; + } + + if (!(instab[opnum].opcode) || !(instab[opnum].fn) && !(as -> skipcond || as -> inmacro)) { // invalid operation code, throw error register_error(as, l, 1, "Invalid operation code '%s'", opc); @@ -131,9 +142,11 @@ return -1; } - // dispatch handler - (instab[opnum].fn)(as, l, &p2, opnum); - + // dispatch handler if we're not ignoring items + if (as -> skipcond == 0 && as -> inmacro == 0 && !(instab[opnum].iscond)) + (instab[opnum].fn)(as, l, &p2, opnum); + +done_line: lwasm_free(opc); if (sym) lwasm_free(sym);