diff options
author | Michal Krol <[email protected]> | 2009-06-09 12:14:40 +0200 |
---|---|---|
committer | Michal Krol <[email protected]> | 2009-06-09 12:14:40 +0200 |
commit | ef8caec29ae73bb2bbeb48f0578d839ef29348cd (patch) | |
tree | 35fec415c64923fcfc9504f8a4993a959b388c3a /src/mesa | |
parent | c534604800e2ea14991acb83fe4c68ffcdb7b661 (diff) |
glsl: Expand nested preprocessor macros.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/shader/slang/slang_preprocess.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index c16a1111322..f9390f75047 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -1012,6 +1012,8 @@ preprocess_source (slang_string *output, const char *source, case TOKEN_DEFINE: { pp_symbol *symbol = NULL; + slang_string replacement; + expand_state es; /* Parse macro name. */ id = (const char *) (&prod[i]); @@ -1054,9 +1056,20 @@ preprocess_source (slang_string *output, const char *source, idlen = _mesa_strlen (id); if (state.cond.top->effective) { pp_annotate (output, ") %s", id); - slang_string_pushs (&symbol->replacement, id, idlen); } + slang_string_init(&replacement); + slang_string_pushs(&replacement, id, idlen); i += idlen + 1; + + /* Expand macro replacement. */ + es.output = &symbol->replacement; + es.input = slang_string_cstr(&replacement); + es.state = &state; + if (!expand(&es, &state.symbols)) { + slang_string_free(&replacement); + goto error; + } + slang_string_free(&replacement); } break; |