summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-06-10 12:24:52 -0600
committerBrian Paul <brianp@vmware.com>2009-06-17 11:30:03 -0600
commitd1056535dcea534ea1b54eb7e3e089fe7367af86 (patch)
treef66dad7ed1b1b6f8967d49f90ace8d17f011e88f /src
parented31da85cac1bc7d42e8efbd00e130ad323aaf35 (diff)
glsl: Expand nested preprocessor macros.
(cherry picked from master, commit ef8caec29ae73bb2bbeb48f0578d839ef29348cd)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c15
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 eb109499312..b2530a6554a 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -1018,6 +1018,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]);
@@ -1060,9 +1062,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;