summaryrefslogtreecommitdiff
path: root/src/glsl/pp/sl_pp_line.c
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-12-20 13:50:16 +0100
committerMichal Krol <michal@vmware.com>2009-12-20 21:18:59 +0100
commitd696cb279d80ccddebcb28ef6b6284bc6bb9430f (patch)
treec2607d192b151b474f80a154c8c9c846507df604 /src/glsl/pp/sl_pp_line.c
parent7631dca25bd390901036b48709e243db961d3a1f (diff)
glsl/pp: Do processing inline with tokenisation.
Diffstat (limited to 'src/glsl/pp/sl_pp_line.c')
-rw-r--r--src/glsl/pp/sl_pp_line.c25
1 files changed, 15 insertions, 10 deletions
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++;
}
}