diff options
author | Keith Kanios <keith@kanios.net> | 2009-07-12 23:39:04 -0500 |
---|---|---|
committer | Keith Kanios <keith@kanios.net> | 2009-07-12 23:39:04 -0500 |
commit | e0725dc769b6b375466e5d1245d3fa1be0087c91 (patch) | |
tree | ce92e6975408e84a124b603a60766f1dfff165fc | |
parent | 852f1eeed56c7ff2c53df0e09f57fe3cd6a395b5 (diff) | |
download | nasm-defid.tar.gz |
preproc: add %[i]defid supportdefid
-rw-r--r-- | pptok.dat | 2 | ||||
-rw-r--r-- | preproc.c | 41 |
2 files changed, 43 insertions, 0 deletions
@@ -50,6 +50,7 @@ %assign %clear %define +%defid %defstr %depend %elif* @@ -64,6 +65,7 @@ %fatal %iassign %idefine +%idefid %idefstr %if* %imacro @@ -2959,6 +2959,47 @@ static int do_directive(Token * tline) free_tlist(origline); return DIRECTIVE_FOUND; + case PP_DEFID: + case PP_IDEFID: + casesense = (i == PP_IDEFID); + + tline = tline->next; + skip_white_(tline); + tline = expand_id(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) { + error(ERR_NONFATAL, "`%s' expects a macro identifier", + pp_directives[i]); + free_tlist(origline); + return DIRECTIVE_FOUND; + } + + ctx = get_ctx(tline->text, &mname, false); + last = tline; + tline = expand_smacro(tline->next); + last->next = NULL; + + while (tok_type_(tline, TOK_WHITESPACE)) + tline = delete_Token(tline); + + p = detoken(tline, false); + if (tok_type_(tline, TOK_STRING)) { + macro_start = new_Token(NULL, TOK_ID, p+1, strlen(p)-2); + } else { + macro_start = new_Token(NULL, TOK_ID, p, strlen(p)); + } + nasm_free(p); + + /* + * We now have a macro name, an implicit parameter count of + * zero, and an id token to use as an expansion. Create + * and store an SMacro. + */ + define_smacro(ctx, mname, casesense, 0, macro_start); + free_tlist(origline); + return DIRECTIVE_FOUND; + case PP_DEFSTR: case PP_IDEFSTR: casesense = (i == PP_DEFSTR); |