From d696cb279d80ccddebcb28ef6b6284bc6bb9430f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Sun, 20 Dec 2009 13:50:16 +0100 Subject: glsl/pp: Do processing inline with tokenisation. --- src/glsl/pp/sl_pp_line.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/glsl/pp/sl_pp_line.c') diff --git a/src/glsl/pp/sl_pp_line.c b/src/glsl/pp/sl_pp_line.c index ed5acc697c..87987fc2ba 100644 --- a/src/glsl/pp/sl_pp_line.c +++ b/src/glsl/pp/sl_pp_line.c @@ -33,39 +33,44 @@ int sl_pp_process_line(struct sl_pp_context *context, - const struct sl_pp_token_info *input, - unsigned int first, - unsigned int last, + struct sl_pp_token_buffer *buffer, struct sl_pp_process_state *pstate) { - unsigned int i; struct sl_pp_process_state state; + int found_end = 0; int line_number = -1; int file_number = -1; unsigned int line; unsigned int file; memset(&state, 0, sizeof(state)); - for (i = first; i < last;) { - switch (input[i].token) { + while (!found_end) { + struct sl_pp_token_info input; + + sl_pp_token_buffer_get(buffer, &input); + switch (input.token) { case SL_PP_WHITESPACE: - i++; break; case SL_PP_IDENTIFIER: - if (sl_pp_macro_expand(context, input, &i, NULL, &state, sl_pp_macro_expand_normal)) { + sl_pp_token_buffer_unget(buffer, &input); + if (sl_pp_macro_expand(context, buffer, NULL, &state, sl_pp_macro_expand_normal)) { free(state.out); return -1; } break; + case SL_PP_NEWLINE: + case SL_PP_EOF: + found_end = 1; + break; + default: - if (sl_pp_process_out(&state, &input[i])) { + if (sl_pp_process_out(&state, &input)) { strcpy(context->error_msg, "out of memory"); free(state.out); return -1; } - i++; } } -- cgit v1.2.3