summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/glcpp-parse.y
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-04-23 14:27:40 +0200
committerChristian König <[email protected]>2011-04-23 14:27:40 +0200
commitfa31b1095eeea97695125ad5770239805bed37da (patch)
tree6c421666719a9a1afc419de33d06f4e66584a8a1 /src/glsl/glcpp/glcpp-parse.y
parent24d76d2966a5c666c9627034e6751621b17024c8 (diff)
parent15eaf8297ecb39337109b95480e61f37a6b20f0a (diff)
Merge remote branch 'origin/master' into pipe-video
Conflicts: configs/linux-dri src/gallium/drivers/r600/r600_pipe.c src/gallium/drivers/r600/r600_state.c src/gallium/include/pipe/p_format.h src/gallium/tests/graw/fragment-shader/frag-abs.sh src/gallium/tests/graw/fragment-shader/frag-add.sh src/gallium/tests/graw/fragment-shader/frag-cb-1d.sh src/gallium/tests/graw/fragment-shader/frag-cb-2d.sh src/gallium/tests/graw/fragment-shader/frag-dp3.sh src/gallium/tests/graw/fragment-shader/frag-dp4.sh src/gallium/tests/graw/fragment-shader/frag-dst.sh src/gallium/tests/graw/fragment-shader/frag-ex2.sh src/gallium/tests/graw/fragment-shader/frag-face.sh src/gallium/tests/graw/fragment-shader/frag-flr.sh src/gallium/tests/graw/fragment-shader/frag-frc.sh src/gallium/tests/graw/fragment-shader/frag-kil.sh src/gallium/tests/graw/fragment-shader/frag-lg2.sh src/gallium/tests/graw/fragment-shader/frag-lit.sh src/gallium/tests/graw/fragment-shader/frag-lrp.sh src/gallium/tests/graw/fragment-shader/frag-mad-immx.sh src/gallium/tests/graw/fragment-shader/frag-mad.sh src/gallium/tests/graw/fragment-shader/frag-max.sh src/gallium/tests/graw/fragment-shader/frag-min.sh src/gallium/tests/graw/fragment-shader/frag-mov.sh src/gallium/tests/graw/fragment-shader/frag-mul.sh src/gallium/tests/graw/fragment-shader/frag-rcp.sh src/gallium/tests/graw/fragment-shader/frag-rsq.sh src/gallium/tests/graw/fragment-shader/frag-sge.sh src/gallium/tests/graw/fragment-shader/frag-slt.sh src/gallium/tests/graw/fragment-shader/frag-srcmod-abs.sh src/gallium/tests/graw/fragment-shader/frag-srcmod-absneg.sh src/gallium/tests/graw/fragment-shader/frag-srcmod-neg.sh src/gallium/tests/graw/fragment-shader/frag-srcmod-swz.sh src/gallium/tests/graw/fragment-shader/frag-sub.sh src/gallium/tests/graw/fragment-shader/frag-tempx.sh src/gallium/tests/graw/fragment-shader/frag-xpd.sh src/gallium/tests/graw/vertex-shader/vert-abs.sh src/gallium/tests/graw/vertex-shader/vert-add.sh src/gallium/tests/graw/vertex-shader/vert-arl.sh src/gallium/tests/graw/vertex-shader/vert-arr.sh src/gallium/tests/graw/vertex-shader/vert-cb-1d.sh src/gallium/tests/graw/vertex-shader/vert-cb-2d.sh src/gallium/tests/graw/vertex-shader/vert-dp3.sh src/gallium/tests/graw/vertex-shader/vert-dp4.sh src/gallium/tests/graw/vertex-shader/vert-dst.sh src/gallium/tests/graw/vertex-shader/vert-ex2.sh src/gallium/tests/graw/vertex-shader/vert-flr.sh src/gallium/tests/graw/vertex-shader/vert-frc.sh src/gallium/tests/graw/vertex-shader/vert-lg2.sh src/gallium/tests/graw/vertex-shader/vert-lit.sh src/gallium/tests/graw/vertex-shader/vert-lrp.sh src/gallium/tests/graw/vertex-shader/vert-mad.sh src/gallium/tests/graw/vertex-shader/vert-max.sh src/gallium/tests/graw/vertex-shader/vert-min.sh src/gallium/tests/graw/vertex-shader/vert-mov.sh src/gallium/tests/graw/vertex-shader/vert-mul.sh src/gallium/tests/graw/vertex-shader/vert-rcp.sh src/gallium/tests/graw/vertex-shader/vert-rsq.sh src/gallium/tests/graw/vertex-shader/vert-sge.sh src/gallium/tests/graw/vertex-shader/vert-slt.sh src/gallium/tests/graw/vertex-shader/vert-srcmod-abs.sh src/gallium/tests/graw/vertex-shader/vert-srcmod-absneg.sh src/gallium/tests/graw/vertex-shader/vert-srcmod-neg.sh src/gallium/tests/graw/vertex-shader/vert-srcmod-swz.sh src/gallium/tests/graw/vertex-shader/vert-sub.sh src/gallium/tests/graw/vertex-shader/vert-xpd.sh src/gallium/tools/trace/dump.py src/gallium/tools/trace/format.py src/gallium/tools/trace/model.py src/gallium/tools/trace/parse.py
Diffstat (limited to 'src/glsl/glcpp/glcpp-parse.y')
-rw-r--r--src/glsl/glcpp/glcpp-parse.y82
1 files changed, 43 insertions, 39 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 1f6e67fa062..6f15e85a122 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;
@@ -1561,6 +1563,7 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser,
token_node_t *node_prev;
token_node_t *node, *last = NULL;
token_list_t *expansion;
+ active_list_t *active_initial = parser->active;
if (list == NULL)
return;
@@ -1573,10 +1576,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 +1586,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
@@ -1617,8 +1618,11 @@ _glcpp_parser_expand_token_list (glcpp_parser_t *parser,
node = node_prev ? node_prev->next : list->head;
}
- while (parser->active)
- parser->active = _active_list_pop (parser->active);
+ /* Remove any lingering effects of this invocation on the
+ * active list. That is, pop until the list looks like it did
+ * at the beginning of this function. */
+ while (parser->active && parser->active != active_initial)
+ _parser_active_list_pop (parser);
list->non_space_tail = list->tail;
}