diff options
author | Carl Worth <[email protected]> | 2011-04-14 15:35:41 -0700 |
---|---|---|
committer | Carl Worth <[email protected]> | 2011-04-14 15:35:41 -0700 |
commit | 02d293c08ee2375fc43b343bfc9b074f33a9063c (patch) | |
tree | ee8a4295f02f821a133f1a87560efbd71076ed08 /src/glsl/glcpp | |
parent | 0b80f2d4c9fd672d75d647104bf0b0fdafec9dda (diff) |
glcpp: Simplify calling convention of parser's active_list functions
These were all written as generic list functions, (accepting and returning
a list to act upon). But they were only ever used with parser->active as
the list. By simply accepting the parser itself, these functions can update
parser->active and now return nothing at all. This makes the code a bit
more compact.
And hopefully the code is no less readable since the functions are also
now renamed to have "_parser_active" in the name for better correlation
with nearby tests of the parser->active field.
Diffstat (limited to 'src/glsl/glcpp')
-rw-r--r-- | src/glsl/glcpp/glcpp-parse.y | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 1f6e67fa062..fdc9467803b 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -95,16 +95,16 @@ _token_list_append_list (token_list_t *list, token_list_t *tail); static int _token_list_equal_ignoring_space (token_list_t *a, token_list_t *b); -static active_list_t * -_active_list_push (active_list_t *list, - const char *identifier, - token_node_t *marker); +static void +_parser_active_list_push (glcpp_parser_t *parser, + const char *identifier, + token_node_t *marker); -static active_list_t * -_active_list_pop (active_list_t *list); +static void +_parser_active_list_pop (glcpp_parser_t *parser); -int -_active_list_contains (active_list_t *list, const char *identifier); +static int +_parser_active_list_contains (glcpp_parser_t *parser, const char *identifier); static void _glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); @@ -1468,7 +1468,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, /* Finally, don't expand this macro if we're already actively * expanding it, (to avoid infinite recursion). */ - if (_active_list_contains (parser->active, identifier)) { + if (_parser_active_list_contains (parser, identifier)) { /* We change the token type here from IDENTIFIER to * OTHER to prevent any future expansion of this * unexpanded token. */ @@ -1498,51 +1498,53 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, return _glcpp_parser_expand_function (parser, node, last); } -/* Push a new identifier onto the active list, returning the new list. +/* Push a new identifier onto the parser's active list. * * Here, 'marker' is the token node that appears in the list after the * expansion of 'identifier'. That is, when the list iterator begins - * examinging 'marker', then it is time to pop this node from the + * examining 'marker', then it is time to pop this node from the * active stack. */ -active_list_t * -_active_list_push (active_list_t *list, - const char *identifier, - token_node_t *marker) +static void +_parser_active_list_push (glcpp_parser_t *parser, + const char *identifier, + token_node_t *marker) { active_list_t *node; - node = ralloc (list, active_list_t); + node = ralloc (parser->active, active_list_t); node->identifier = ralloc_strdup (node, identifier); node->marker = marker; - node->next = list; + node->next = parser->active; - return node; + parser->active = node; } -active_list_t * -_active_list_pop (active_list_t *list) +static void +_parser_active_list_pop (glcpp_parser_t *parser) { - active_list_t *node = list; + active_list_t *node = parser->active; - if (node == NULL) - return NULL; + if (node == NULL) { + parser->active = NULL; + return; + } - node = list->next; - ralloc_free (list); + node = parser->active->next; + ralloc_free (parser->active); - return node; + parser->active = node; } -int -_active_list_contains (active_list_t *list, const char *identifier) +static int +_parser_active_list_contains (glcpp_parser_t *parser, const char *identifier) { active_list_t *node; - if (list == NULL) + if (parser->active == NULL) return 0; - for (node = list; node; node = node->next) + for (node = parser->active; node; node = node->next) if (strcmp (node->identifier, identifier) == 0) return 1; @@ -1573,10 +1575,8 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, while (node) { while (parser->active && parser->active->marker == node) - parser->active = _active_list_pop (parser->active); + _parser_active_list_pop (parser); - /* Find the expansion for node, which will replace all - * nodes from node to last, inclusive. */ expansion = _glcpp_parser_expand_node (parser, node, &last); if (expansion) { token_node_t *n; @@ -1585,12 +1585,12 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, while (parser->active && parser->active->marker == n) { - parser->active = _active_list_pop (parser->active); + _parser_active_list_pop (parser); } - parser->active = _active_list_push (parser->active, - node->token->value.str, - last->next); + _parser_active_list_push (parser, + node->token->value.str, + last->next); /* Splice expansion into list, supporting a * simple deletion if the expansion is @@ -1618,7 +1618,7 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser, } while (parser->active) - parser->active = _active_list_pop (parser->active); + _parser_active_list_pop (parser); list->non_space_tail = list->tail; } |