diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-06-16 12:18:00 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2010-06-21 11:31:54 -0700 |
commit | 04ba86a536d76ef24c749e16c785c1634b9187c9 (patch) | |
tree | b9b1d64f0c45a59d8b1e192a3ab363df915ee14e /main.cpp | |
parent | 2848c4c183ea0aaca2ca0a23a13196c786403a5c (diff) |
Make the main compiler call the preprocessor.
By using a single function, the main compiler doesn't need to include
glcpp.h, which currently has a lot of details about the preprocessor
internals. In particular, this prevents the two yacc grammars from
seeing each other, which would be rather messy to sort out.
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -124,9 +124,17 @@ compile_shader(struct glsl_shader *shader) state.loop_or_switch_nesting = NULL; state.ARB_texture_rectangle_enable = true; - _mesa_glsl_lexer_ctor(& state, shader->Source, shader->SourceLen); - _mesa_glsl_parse(& state); - _mesa_glsl_lexer_dtor(& state); + /* Create a new context for the preprocessor output. Ultimately, this + * should probably be the parser context, but there isn't one yet. + */ + const char *source = shader->Source; + state.error = preprocess(shader, &source, &shader->SourceLen); + + if (!state.error) { + _mesa_glsl_lexer_ctor(& state, source, shader->SourceLen); + _mesa_glsl_parse(& state); + _mesa_glsl_lexer_dtor(& state); + } if (dump_ast) { foreach_list_const(n, &state.translation_unit) { |