From: Carl Worth Date: Fri, 28 May 2010 15:00:43 +0000 (-0700) Subject: Revert "Add support for an object-to-function chain with the parens in the content." X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=95ec433d59be234cf2695ae091cee4ace3314d21;p=mesa.git Revert "Add support for an object-to-function chain with the parens in the content." This reverts commit 7db2402a8009772a3f10d19cfc7f30be9ee79295 It doesn't revert the new test case from that commit, just the extremely ugly second-pass implementation. --- diff --git a/glcpp-parse.y b/glcpp-parse.y index 5b2d0d3927a..f4cb72a133f 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -958,9 +958,9 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser, * needs further expansion. */ static int -_expand_token_onto (glcpp_parser_t *parser, - token_t *token, - token_list_t *result) +_glcpp_parser_expand_token_onto (glcpp_parser_t *parser, + token_t *token, + token_list_t *result) { const char *identifier; macro_t *macro; @@ -1117,10 +1117,10 @@ _arguments_parse (argument_list_t *arguments, token_node_t **node_ret) /* Prints the expansion of *node (consuming further tokens from the * list as necessary). Upon return *node will be the last consumed * node, such that further processing can continue with node->next. */ -static function_status_t -_expand_function_onto (glcpp_parser_t *parser, - token_node_t **node_ret, - token_list_t *result) +static void +_glcpp_parser_expand_function_onto (glcpp_parser_t *parser, + token_node_t **node_ret, + token_list_t *result) { macro_t *macro; token_node_t *node; @@ -1145,7 +1145,7 @@ _expand_function_onto (glcpp_parser_t *parser, break; case FUNCTION_NOT_A_FUNCTION: _token_list_append (result, node->token); - return FUNCTION_NOT_A_FUNCTION; + return; case FUNCTION_UNBALANCED_PARENTHESES: fprintf (stderr, "Error: Macro %s call has unbalanced parentheses\n", identifier); @@ -1154,7 +1154,7 @@ _expand_function_onto (glcpp_parser_t *parser, if (macro->replacements == NULL) { talloc_free (arguments); - return FUNCTION_STATUS_SUCCESS; + return; } if (! ((_argument_list_length (arguments) == @@ -1168,7 +1168,7 @@ _expand_function_onto (glcpp_parser_t *parser, identifier, _argument_list_length (arguments), _string_list_length (macro->parameters)); - exit (1); + return; } /* Perform argument substitution on the replacement list. */ @@ -1246,8 +1246,6 @@ _expand_function_onto (glcpp_parser_t *parser, _string_list_pop (parser->active); talloc_free (arguments); - - return FUNCTION_STATUS_SUCCESS; } static void @@ -1256,50 +1254,19 @@ _glcpp_parser_expand_token_list_onto (glcpp_parser_t *parser, token_list_t *result) { token_node_t *node; - token_list_t *intermediate, *list_orig = list; - int i, need_rescan = 0; if (list == NULL || list->head == NULL) return; - intermediate = _token_list_create (parser); - - /* XXX: The two-pass expansion here is really ugly. The - * problem this is solving is that we can expand a macro into - * a function-like macro name, and then we need to recognize - * that as a function-like macro, but perhaps the parentheses - * and arguments aren't on the token list yet, (since they are - * in the actual content so they are part of what we are - * expanding. - * - * This ugly hack works, but is messy, fragile, and hard to - * maintain. I think a cleaner solution would separate the - * notions of expanding and appending and avoid this problem - * altogether. - */ - - for (i = 0; i < 2; i++) { - if (i == 1) { - list = intermediate; - intermediate = _token_list_create (parser); - } - for (node = list->head; node; node = node->next) + for (node = list->head; node; node = node->next) + { + if (_glcpp_parser_expand_token_onto (parser, node->token, + result)) { - if (_expand_token_onto (parser, node->token, - intermediate)) - { - if (_expand_function_onto (parser, &node, - intermediate)) - { - need_rescan = 1; - } - } + _glcpp_parser_expand_function_onto (parser, &node, + result); } - if (list != list_orig) - talloc_free (list); } - - _token_list_append_list (result, intermediate); } void