On 08.10.2016 12:58, Marek Olšák wrote:
From: Marek Olšák <marek.ol...@amd.com>

---
 src/compiler/glsl/glcpp/glcpp-lex.l   |   2 +-
 src/compiler/glsl/glcpp/glcpp-parse.y | 203 +++++++++++++++-------------------
 src/compiler/glsl/glcpp/glcpp.h       |   1 +
 3 files changed, 94 insertions(+), 112 deletions(-)

diff --git a/src/compiler/glsl/glcpp/glcpp-lex.l 
b/src/compiler/glsl/glcpp/glcpp-lex.l
index d09441a..f4a6876 100644
--- a/src/compiler/glsl/glcpp/glcpp-lex.l
+++ b/src/compiler/glsl/glcpp/glcpp-lex.l
[snip]
@@ -1002,51 +994,50 @@ _token_list_append_list(token_list_t *list, token_list_t 
*tail)
       list->head = tail->head;
    } else {
       list->tail->next = tail->head;
    }

    list->tail = tail->tail;
    list->non_space_tail = tail->non_space_tail;
 }

 static token_list_t *
-_token_list_copy(void *ctx, token_list_t *other)
+_token_list_copy(glcpp_parser_t *parser, token_list_t *other)
 {
    token_list_t *copy;
    token_node_t *node;

    if (other == NULL)
       return NULL;

-   copy = _token_list_create (ctx);
+   copy = _token_list_create (parser);
    for (node = other->head; node; node = node->next) {
-      token_t *new_token = ralloc (copy, token_t);
+      token_t *new_token = linear_alloc_child(parser->linalloc, 
sizeof(token_t));
       *new_token = *node->token;
-      _token_list_append (copy, new_token);
+      _token_list_append (parser, copy, new_token);
    }

    return copy;
 }

 static void
 _token_list_trim_trailing_space(token_list_t *list)
 {
    token_node_t *tail, *next;

    if (list->non_space_tail) {
       tail = list->non_space_tail->next;
       list->non_space_tail->next = NULL;
       list->tail = list->non_space_tail;

       while (tail) {
          next = tail->next;
-         ralloc_free (tail);
          tail = next;
       }

This whole loop can be dropped now.


    }
 }

 static int
 _token_list_is_empty_ignoring_space(token_list_t *l)
 {
    token_node_t *n;

@@ -1177,69 +1168,70 @@ _token_print(char **out, size_t *len, token_t *token)
    case PLACEHOLDER:
       /* Nothing to print. */
       break;
    default:
       assert(!"Error: Don't know how to print token.");

       break;
    }
 }

-/* Return a new token (ralloc()ed off of 'token') formed by pasting
- * 'token' and 'other'. Note that this function may return 'token' or
- * 'other' directly rather than allocating anything new.
+/* Return a new token formed by pasting 'token' and 'other'. Note that this
+ * function may return 'token' or 'other' directly rather than allocating
+ * anything new.
  *
  * Caution: Only very cursory error-checking is performed to see if
  * the final result is a valid single token. */
 static token_t *
-_token_paste(glcpp_parser_t *parser, token_t *token, token_t *other)
+_token_paste(glcpp_parser_t *parser, token_list_t *list, token_t *token,
+             token_t *other)

I seem to be blind... where is list used?

Nicolai

 {
    token_t *combined = NULL;

    /* Pasting a placeholder onto anything makes no change. */
    if (other->type == PLACEHOLDER)
       return token;

    /* When 'token' is a placeholder, just return 'other'. */
    if (token->type == PLACEHOLDER)
       return other;

    /* A very few single-character punctuators can be combined
     * with another to form a multi-character punctuator. */
    switch (token->type) {
    case '<':
       if (other->type == '<')
-         combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
+         combined = _token_create_ival (parser, LEFT_SHIFT, LEFT_SHIFT);
       else if (other->type == '=')
-         combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
+         combined = _token_create_ival (parser, LESS_OR_EQUAL, LESS_OR_EQUAL);
       break;
    case '>':
       if (other->type == '>')
-         combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
+         combined = _token_create_ival (parser, RIGHT_SHIFT, RIGHT_SHIFT);
       else if (other->type == '=')
-         combined = _token_create_ival (token, GREATER_OR_EQUAL, 
GREATER_OR_EQUAL);
+         combined = _token_create_ival (parser, GREATER_OR_EQUAL, 
GREATER_OR_EQUAL);
       break;
    case '=':
       if (other->type == '=')
-         combined = _token_create_ival (token, EQUAL, EQUAL);
+         combined = _token_create_ival (parser, EQUAL, EQUAL);
       break;
    case '!':
       if (other->type == '=')
-         combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
+         combined = _token_create_ival (parser, NOT_EQUAL, NOT_EQUAL);
       break;
    case '&':
       if (other->type == '&')
-         combined = _token_create_ival (token, AND, AND);
+         combined = _token_create_ival (parser, AND, AND);
       break;
    case '|':
       if (other->type == '|')
-         combined = _token_create_ival (token, OR, OR);
+         combined = _token_create_ival (parser, OR, OR);
       break;
    }

    if (combined != NULL) {
       /* Inherit the location from the first token */
       combined->location = token->location;
       return combined;
    }

    /* Two string-valued (or integer) tokens can usually just be
@@ -1269,37 +1261,37 @@ _token_paste(glcpp_parser_t *parser, token_t *token, 
token_t *other)
          case INTEGER:
             if (other->value.ival < 0)
                goto FAIL;
             break;
          default:
             goto FAIL;
          }
       }

       if (token->type == INTEGER)
-         str = ralloc_asprintf (token, "%" PRIiMAX, token->value.ival);
+         str = linear_asprintf(parser->linalloc, "%" PRIiMAX, 
token->value.ival);
       else
-         str = ralloc_strdup (token, token->value.str);
+         str = linear_strdup(parser->linalloc, token->value.str);

       if (other->type == INTEGER)
-         ralloc_asprintf_append (&str, "%" PRIiMAX, other->value.ival);
+         linear_asprintf_append(parser->linalloc, &str, "%" PRIiMAX, 
other->value.ival);
       else
-         ralloc_strcat (&str, other->value.str);
+         linear_strcat(parser->linalloc, &str, other->value.str);

       /* New token is same type as original token, unless we
        * started with an integer, in which case we will be
        * creating an integer-string. */
       combined_type = token->type;
       if (combined_type == INTEGER)
          combined_type = INTEGER_STRING;

-      combined = _token_create_str (token, combined_type, str);
+      combined = _token_create_str (parser, combined_type, str);
       combined->location = token->location;
       return combined;
    }

     FAIL:
    glcpp_error (&token->location, parser, "");
    ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "Pasting 
\"");
    _token_print (&parser->info_log, &parser->info_log_length, token);
    ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "\" and 
\"");
    _token_print (&parser->info_log, &parser->info_log_length, other);
@@ -1328,34 +1320,35 @@ yyerror(YYLTYPE *locp, glcpp_parser_t *parser, const 
char *error)
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to