• Home
  • Raw
  • Download

Lines Matching +full:node +full:- +full:version

133 /* Perform macro expansion in-place on the given list. */
154 _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version,
176 %pure-parser
177 %error-verbose
180 %initial-action {
188 %parse-param {glcpp_parser_t *parser}
189 %lex-param {glcpp_parser_t *parser}
194 * HASH, DEFINE, and VERSION) to avoid conflicts with other symbols,
212 %left '+' '-'
230 _mesa_string_buffer_append_char(parser->output, '\n');
237 if (parser->is_gles && $2.undefined_macro)
242 if (parser->is_gles && $2.undefined_macro)
247 parser->has_new_line_number = 1;
248 parser->new_line_number = $2;
249 _mesa_string_buffer_printf(parser->output, "#line %" PRIiMAX "\n", $2);
252 parser->has_new_line_number = 1;
253 parser->new_line_number = $2;
254 parser->has_new_source_number = 1;
255 parser->new_source_number = $3;
256 _mesa_string_buffer_printf(parser->output,
261 parser->has_new_line_number = 1;
262 parser->new_line_number = $2;
263 _mesa_string_buffer_printf(parser->output,
283 _mesa_string_buffer_append_char(parser->output, '\n');
288 if (parser->skip_stack == NULL ||
289 parser->skip_stack->type == SKIP_NO_SKIP)
305 * It is an error to undefine or to redefine a built-in
306 * (pre-defined) macro name.
321 * such a name results in a compile-time error.
326 glcpp_error(& @1, parser, "Built-in (pre-defined)"
329 if (parser->is_gles
330 && parser->version >= 300
334 glcpp_error(& @1, parser, "Built-in (pre-defined)"
336 } else if (parser->is_gles && parser->version <= 300) {
347 entry = _mesa_hash_table_search (parser->defines, $3);
349 _mesa_hash_table_remove (parser->defines, entry);
353 size_t include_cursor = _mesa_get_shader_include_cursor(parser->gl_ctx->Shared);
358 _mesa_set_shader_include_cursor(parser->gl_ctx->Shared, 0);
361 char *path = strndup(start + 1, strlen(start + 1) - 1);
364 _mesa_lookup_shader_include(parser->gl_ctx, path, false);
372 glcpp_parser_create(parser->gl_ctx, parser->extensions, parser->state);
373 tmp_parser->version_set = true;
374 tmp_parser->version = parser->version;
386 hash_table_call_foreach(parser->defines,
395 _mesa_string_buffer_printf(parser->output, "#include\n");
401 _mesa_string_buffer_printf(parser->info_log, "%s",
402 tmp_parser->info_log->buf);
403 _mesa_string_buffer_printf(parser->output, "%s",
404 tmp_parser->output->buf);
415 hash_table_call_foreach(tmp_parser->defines,
420 glcpp_lex_destroy(tmp_parser->scanner);
421 _mesa_hash_table_destroy(tmp_parser->defines, NULL);
424 _mesa_set_shader_include_cursor(parser->gl_ctx->Shared, include_cursor);
429 * simply push a new 0-valued 'if' onto the skip
434 if (parser->skip_stack == NULL ||
435 parser->skip_stack->type == SKIP_NO_SKIP)
444 parser->skip_stack->type = SKIP_TO_ENDIF;
450 if (parser->skip_stack == NULL ||
451 parser->skip_stack->type == SKIP_NO_SKIP)
459 _mesa_hash_table_search(parser->defines, $3);
460 macro_t *macro = entry ? entry->data : NULL;
465 _mesa_hash_table_search(parser->defines, $3);
466 macro_t *macro = entry ? entry->data : NULL;
472 * simply change to a 0-valued 'elif' on the skip
477 if (parser->skip_stack &&
478 parser->skip_stack->type == SKIP_TO_ELSE)
484 else if (parser->skip_stack &&
485 parser->skip_stack->has_else)
498 if (parser->skip_stack &&
499 parser->skip_stack->type == SKIP_TO_ELSE)
503 else if (parser->skip_stack &&
504 parser->skip_stack->has_else)
515 | HASH_TOKEN ELSE { parser->lexing_directive = 1; } NEWLINE {
516 if (parser->skip_stack &&
517 parser->skip_stack->has_else)
524 if (parser->skip_stack)
525 parser->skip_stack->has_else = true;
532 if (parser->version_set) {
533 glcpp_error(& @1, parser, "#version must appear on the first line");
538 if (parser->version_set) {
539 glcpp_error(& @1, parser, "#version must appear on the first line");
547 _mesa_string_buffer_printf(parser->output, "#%s", $2);
559 glcpp_error (& @1, parser, "Illegal non-directive after #");
576 glcpp_error(&@1, parser, "invalid #version \"%s\" (not a decimal constant)", $1);
590 if (parser->is_gles)
591 $$.undefined_macro = linear_strdup(parser->linalloc, $1);
598 /* Short-circuit: Only flag undefined from right side
609 /* Short-circuit: Only flag undefined from right-side
694 | expression '-' expression {
695 $$.value = $1.value - $3.value;
747 | '-' expression %prec UNARY {
748 $$.value = - $2.value;
784 if (parser->gl_ctx->Const.AllowExtraPPTokens)
793 parser->space_tokens = 1;
806 $$->location = yylloc;
810 $$->location = yylloc;
814 $$->location = yylloc;
818 $$->location = yylloc;
822 $$->location = yylloc;
826 $$->location = yylloc;
830 $$->location = yylloc;
845 | '-' { $$ = '-'; }
877 list = linear_alloc_child(parser->linalloc, sizeof(string_list_t));
878 list->head = NULL;
879 list->tail = NULL;
888 string_node_t *node; in _string_list_append_item() local
890 node = linear_alloc_child(parser->linalloc, sizeof(string_node_t)); in _string_list_append_item()
891 node->str = linear_strdup(parser->linalloc, str); in _string_list_append_item()
893 node->next = NULL; in _string_list_append_item()
895 if (list->head == NULL) { in _string_list_append_item()
896 list->head = node; in _string_list_append_item()
898 list->tail->next = node; in _string_list_append_item()
901 list->tail = node; in _string_list_append_item()
907 string_node_t *node; in _string_list_contains() local
913 for (i = 0, node = list->head; node; i++, node = node->next) { in _string_list_contains()
914 if (strcmp (node->str, member) == 0) { in _string_list_contains()
928 string_node_t *node, *dup; in _string_list_has_duplicate() local
933 for (node = list->head; node; node = node->next) { in _string_list_has_duplicate()
934 for (dup = node->next; dup; dup = dup->next) { in _string_list_has_duplicate()
935 if (strcmp (node->str, dup->str) == 0) in _string_list_has_duplicate()
936 return node->str; in _string_list_has_duplicate()
947 string_node_t *node; in _string_list_length() local
952 for (node = list->head; node; node = node->next) in _string_list_length()
969 for (node_a = a->head, node_b = b->head; in _string_list_equal()
971 node_a = node_a->next, node_b = node_b->next) in _string_list_equal()
973 if (strcmp (node_a->str, node_b->str)) in _string_list_equal()
988 list = linear_alloc_child(parser->linalloc, sizeof(argument_list_t)); in _argument_list_create()
989 list->head = NULL; in _argument_list_create()
990 list->tail = NULL; in _argument_list_create()
999 argument_node_t *node; in _argument_list_append() local
1001 node = linear_alloc_child(parser->linalloc, sizeof(argument_node_t)); in _argument_list_append()
1002 node->argument = argument; in _argument_list_append()
1004 node->next = NULL; in _argument_list_append()
1006 if (list->head == NULL) { in _argument_list_append()
1007 list->head = node; in _argument_list_append()
1009 list->tail->next = node; in _argument_list_append()
1012 list->tail = node; in _argument_list_append()
1019 argument_node_t *node; in _argument_list_length() local
1024 for (node = list->head; node; node = node->next) in _argument_list_length()
1033 argument_node_t *node; in _argument_list_member_at() local
1039 node = list->head; in _argument_list_member_at()
1041 node = node->next; in _argument_list_member_at()
1042 if (node == NULL) in _argument_list_member_at()
1046 if (node) in _argument_list_member_at()
1047 return node->argument; in _argument_list_member_at()
1057 token = linear_alloc_child(parser->linalloc, sizeof(token_t)); in _token_create_str()
1058 token->type = type; in _token_create_str()
1059 token->value.str = str; in _token_create_str()
1069 token = linear_alloc_child(parser->linalloc, sizeof(token_t)); in _token_create_ival()
1070 token->type = type; in _token_create_ival()
1071 token->value.ival = ival; in _token_create_ival()
1081 list = linear_alloc_child(parser->linalloc, sizeof(token_list_t)); in _token_list_create()
1082 list->head = NULL; in _token_list_create()
1083 list->tail = NULL; in _token_list_create()
1084 list->non_space_tail = NULL; in _token_list_create()
1092 token_node_t *node; in _token_list_append() local
1094 node = linear_alloc_child(parser->linalloc, sizeof(token_node_t)); in _token_list_append()
1095 node->token = token; in _token_list_append()
1096 node->next = NULL; in _token_list_append()
1098 if (list->head == NULL) { in _token_list_append()
1099 list->head = node; in _token_list_append()
1101 list->tail->next = node; in _token_list_append()
1104 list->tail = node; in _token_list_append()
1105 if (token->type != SPACE) in _token_list_append()
1106 list->non_space_tail = node; in _token_list_append()
1112 if (tail == NULL || tail->head == NULL) in _token_list_append_list()
1115 if (list->head == NULL) { in _token_list_append_list()
1116 list->head = tail->head; in _token_list_append_list()
1118 list->tail->next = tail->head; in _token_list_append_list()
1121 list->tail = tail->tail; in _token_list_append_list()
1122 list->non_space_tail = tail->non_space_tail; in _token_list_append_list()
1129 token_node_t *node; in _token_list_copy() local
1135 for (node = other->head; node; node = node->next) { in _token_list_copy()
1136 token_t *new_token = linear_alloc_child(parser->linalloc, sizeof(token_t)); in _token_list_copy()
1137 *new_token = *node->token; in _token_list_copy()
1147 if (list->non_space_tail) { in _token_list_trim_trailing_space()
1148 list->non_space_tail->next = NULL; in _token_list_trim_trailing_space()
1149 list->tail = list->non_space_tail; in _token_list_trim_trailing_space()
1161 n = l->head; in _token_list_is_empty_ignoring_space()
1162 while (n != NULL && n->token->type == SPACE) in _token_list_is_empty_ignoring_space()
1163 n = n->next; in _token_list_is_empty_ignoring_space()
1179 node_a = a->head; in _token_list_equal_ignoring_space()
1180 node_b = b->head; in _token_list_equal_ignoring_space()
1188 if (node_a == NULL && node_b->token->type == SPACE) { in _token_list_equal_ignoring_space()
1189 while (node_b && node_b->token->type == SPACE) in _token_list_equal_ignoring_space()
1190 node_b = node_b->next; in _token_list_equal_ignoring_space()
1196 if (node_b == NULL && node_a->token->type == SPACE) { in _token_list_equal_ignoring_space()
1197 while (node_a && node_a->token->type == SPACE) in _token_list_equal_ignoring_space()
1198 node_a = node_a->next; in _token_list_equal_ignoring_space()
1210 if (node_a->token->type == SPACE && node_b->token->type == SPACE) { in _token_list_equal_ignoring_space()
1211 while (node_a && node_a->token->type == SPACE) in _token_list_equal_ignoring_space()
1212 node_a = node_a->next; in _token_list_equal_ignoring_space()
1213 while (node_b && node_b->token->type == SPACE) in _token_list_equal_ignoring_space()
1214 node_b = node_b->next; in _token_list_equal_ignoring_space()
1218 if (node_a->token->type != node_b->token->type) in _token_list_equal_ignoring_space()
1221 switch (node_a->token->type) { in _token_list_equal_ignoring_space()
1223 if (node_a->token->value.ival != node_b->token->value.ival) { in _token_list_equal_ignoring_space()
1230 if (strcmp(node_a->token->value.str, node_b->token->value.str)) { in _token_list_equal_ignoring_space()
1236 node_a = node_a->next; in _token_list_equal_ignoring_space()
1237 node_b = node_b->next; in _token_list_equal_ignoring_space()
1246 if (token->type < 256) { in _token_print()
1247 _mesa_string_buffer_append_char(out, token->type); in _token_print()
1251 switch (token->type) { in _token_print()
1253 _mesa_string_buffer_printf(out, "%" PRIiMAX, token->value.ival); in _token_print()
1259 _mesa_string_buffer_append(out, token->value.str); in _token_print()
1295 _mesa_string_buffer_append(out, "--"); in _token_print()
1314 * Caution: Only very cursory error-checking is performed to see if
1322 if (other->type == PLACEHOLDER) in _token_paste()
1326 if (token->type == PLACEHOLDER) in _token_paste()
1329 /* A very few single-character punctuators can be combined in _token_paste()
1330 * with another to form a multi-character punctuator. */ in _token_paste()
1331 switch (token->type) { in _token_paste()
1333 if (other->type == '<') in _token_paste()
1335 else if (other->type == '=') in _token_paste()
1339 if (other->type == '>') in _token_paste()
1341 else if (other->type == '=') in _token_paste()
1345 if (other->type == '=') in _token_paste()
1349 if (other->type == '=') in _token_paste()
1353 if (other->type == '&') in _token_paste()
1357 if (other->type == '|') in _token_paste()
1364 combined->location = token->location; in _token_paste()
1368 /* Two string-valued (or integer) tokens can usually just be in _token_paste()
1377 …if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING || token->… in _token_paste()
1378 …(other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING || other->type… in _token_paste()
1384 * non-integer, (that is, only digits can be in _token_paste()
1386 if (token->type == INTEGER_STRING || token->type == INTEGER) { in _token_paste()
1387 switch (other->type) { in _token_paste()
1389 if (other->value.str[0] < '0' || other->value.str[0] > '9') in _token_paste()
1393 if (other->value.ival < 0) in _token_paste()
1401 if (token->type == INTEGER) in _token_paste()
1402 str = linear_asprintf(parser->linalloc, "%" PRIiMAX, token->value.ival); in _token_paste()
1404 str = linear_strdup(parser->linalloc, token->value.str); in _token_paste()
1406 if (other->type == INTEGER) in _token_paste()
1407 linear_asprintf_append(parser->linalloc, &str, "%" PRIiMAX, other->value.ival); in _token_paste()
1409 linear_strcat(parser->linalloc, &str, other->value.str); in _token_paste()
1413 * creating an integer-string. */ in _token_paste()
1414 combined_type = token->type; in _token_paste()
1419 combined->location = token->location; in _token_paste()
1424 glcpp_error (&token->location, parser, ""); in _token_paste()
1425 _mesa_string_buffer_append(parser->info_log, "Pasting \""); in _token_paste()
1426 _token_print(parser->info_log, token); in _token_paste()
1427 _mesa_string_buffer_append(parser->info_log, "\" and \""); in _token_paste()
1428 _token_print(parser->info_log, other); in _token_paste()
1429 _mesa_string_buffer_append(parser->info_log, "\" does not give a valid preprocessing token.\n"); in _token_paste()
1437 token_node_t *node; in _token_list_print() local
1442 for (node = list->head; node; node = node->next) in _token_list_print()
1443 _token_print(parser->output, node->token); in _token_list_print()
1466 * to minimize total amount of allocated memory during shader-db run.
1478 glcpp_lex_init_extra (parser, &parser->scanner); in glcpp_parser_create()
1479 parser->defines = _mesa_hash_table_create(NULL, _mesa_hash_string, in glcpp_parser_create()
1481 parser->linalloc = linear_alloc_parent(parser, 0); in glcpp_parser_create()
1482 parser->active = NULL; in glcpp_parser_create()
1483 parser->lexing_directive = 0; in glcpp_parser_create()
1484 parser->lexing_version_directive = 0; in glcpp_parser_create()
1485 parser->space_tokens = 1; in glcpp_parser_create()
1486 parser->last_token_was_newline = 0; in glcpp_parser_create()
1487 parser->last_token_was_space = 0; in glcpp_parser_create()
1488 parser->first_non_space_token_this_line = 1; in glcpp_parser_create()
1489 parser->newline_as_space = 0; in glcpp_parser_create()
1490 parser->in_control_line = 0; in glcpp_parser_create()
1491 parser->paren_count = 0; in glcpp_parser_create()
1492 parser->commented_newlines = 0; in glcpp_parser_create()
1494 parser->skip_stack = NULL; in glcpp_parser_create()
1495 parser->skipping = 0; in glcpp_parser_create()
1497 parser->lex_from_list = NULL; in glcpp_parser_create()
1498 parser->lex_from_node = NULL; in glcpp_parser_create()
1500 parser->output = _mesa_string_buffer_create(parser, in glcpp_parser_create()
1502 parser->info_log = _mesa_string_buffer_create(parser, in glcpp_parser_create()
1504 parser->error = 0; in glcpp_parser_create()
1506 parser->gl_ctx = gl_ctx; in glcpp_parser_create()
1507 parser->extensions = extensions; in glcpp_parser_create()
1508 parser->extension_list = &gl_ctx->Extensions; in glcpp_parser_create()
1509 parser->state = state; in glcpp_parser_create()
1510 parser->api = gl_ctx->API; in glcpp_parser_create()
1511 parser->version = 0; in glcpp_parser_create()
1512 parser->version_set = false; in glcpp_parser_create()
1514 parser->has_new_line_number = 0; in glcpp_parser_create()
1515 parser->new_line_number = 1; in glcpp_parser_create()
1516 parser->has_new_source_number = 0; in glcpp_parser_create()
1517 parser->new_source_number = 0; in glcpp_parser_create()
1519 parser->is_gles = false; in glcpp_parser_create()
1527 glcpp_lex_destroy (parser->scanner); in glcpp_parser_destroy()
1528 _mesa_hash_table_destroy(parser->defines, NULL); in glcpp_parser_destroy()
1539 /* Find a set of function-like macro arguments by looking for a
1542 * When called, 'node' should be the opening-parenthesis token, (or
1544 * be the last consumed node, (corresponding to the closing right
1556 * simply that the macro name should be treated as a non-macro.
1564 argument_list_t *arguments, token_node_t *node, in _arguments_parse() argument
1570 node = node->next; in _arguments_parse()
1573 while (node && node->token->type == SPACE) in _arguments_parse()
1574 node = node->next; in _arguments_parse()
1576 if (node == NULL || node->token->type != '(') in _arguments_parse()
1579 node = node->next; in _arguments_parse()
1584 for (paren_count = 1; node; node = node->next) { in _arguments_parse()
1585 if (node->token->type == '(') { in _arguments_parse()
1587 } else if (node->token->type == ')') { in _arguments_parse()
1588 paren_count--; in _arguments_parse()
1593 if (node->token->type == ',' && paren_count == 1) { in _arguments_parse()
1598 if (argument->head == NULL) { in _arguments_parse()
1600 if (node->token->type == SPACE) in _arguments_parse()
1603 _token_list_append(parser, argument, node->token); in _arguments_parse()
1610 *last = node; in _arguments_parse()
1619 token_t *node; in _token_list_create_with_one_ival() local
1622 node = _token_create_ival(parser, type, ival); in _token_list_create_with_one_ival()
1623 _token_list_append(parser, list, node); in _token_list_create_with_one_ival()
1640 /* Evaluate a DEFINED token node (based on subsequent tokens in the list).
1642 * Note: This function must only be called when "node" is a DEFINED token,
1645 * If "node" is followed, (ignoring any SPACE tokens), by an IDENTIFIER token
1653 * In either case, *last will be updated to the last node in the list
1657 * In all other cases, (such as "node is the final node of the list", or
1659 * preprocessor error, returns -1 and *last will not be set.
1662 _glcpp_parser_evaluate_defined(glcpp_parser_t *parser, token_node_t *node, in _glcpp_parser_evaluate_defined() argument
1665 token_node_t *argument, *defined = node; in _glcpp_parser_evaluate_defined()
1667 assert(node->token->type == DEFINED); in _glcpp_parser_evaluate_defined()
1669 node = node->next; in _glcpp_parser_evaluate_defined()
1672 while (node && node->token->type == SPACE) in _glcpp_parser_evaluate_defined()
1673 node = node->next; in _glcpp_parser_evaluate_defined()
1675 if (node == NULL) in _glcpp_parser_evaluate_defined()
1678 if (node->token->type == IDENTIFIER || node->token->type == OTHER) { in _glcpp_parser_evaluate_defined()
1679 argument = node; in _glcpp_parser_evaluate_defined()
1680 } else if (node->token->type == '(') { in _glcpp_parser_evaluate_defined()
1681 node = node->next; in _glcpp_parser_evaluate_defined()
1684 while (node && node->token->type == SPACE) in _glcpp_parser_evaluate_defined()
1685 node = node->next; in _glcpp_parser_evaluate_defined()
1687 if (node == NULL || (node->token->type != IDENTIFIER && in _glcpp_parser_evaluate_defined()
1688 node->token->type != OTHER)) { in _glcpp_parser_evaluate_defined()
1692 argument = node; in _glcpp_parser_evaluate_defined()
1694 node = node->next; in _glcpp_parser_evaluate_defined()
1697 while (node && node->token->type == SPACE) in _glcpp_parser_evaluate_defined()
1698 node = node->next; in _glcpp_parser_evaluate_defined()
1700 if (node == NULL || node->token->type != ')') in _glcpp_parser_evaluate_defined()
1706 *last = node; in _glcpp_parser_evaluate_defined()
1708 return _mesa_hash_table_search(parser->defines, in _glcpp_parser_evaluate_defined()
1709 argument->token->value.str) ? 1 : 0; in _glcpp_parser_evaluate_defined()
1712 glcpp_error (&defined->token->location, parser, in _glcpp_parser_evaluate_defined()
1714 return -1; in _glcpp_parser_evaluate_defined()
1723 token_node_t *node, *node_prev, *replacement, *last = NULL; in _glcpp_parser_evaluate_defined_in_list() local
1730 node = list->head; in _glcpp_parser_evaluate_defined_in_list()
1732 while (node) { in _glcpp_parser_evaluate_defined_in_list()
1734 if (node->token->type != DEFINED) in _glcpp_parser_evaluate_defined_in_list()
1737 value = _glcpp_parser_evaluate_defined (parser, node, &last); in _glcpp_parser_evaluate_defined_in_list()
1738 if (value == -1) in _glcpp_parser_evaluate_defined_in_list()
1741 replacement = linear_alloc_child(parser->linalloc, sizeof(token_node_t)); in _glcpp_parser_evaluate_defined_in_list()
1742 replacement->token = _token_create_ival (parser, INTEGER, value); in _glcpp_parser_evaluate_defined_in_list()
1744 /* Splice replacement node into list, replacing from "node" in _glcpp_parser_evaluate_defined_in_list()
1747 node_prev->next = replacement; in _glcpp_parser_evaluate_defined_in_list()
1749 list->head = replacement; in _glcpp_parser_evaluate_defined_in_list()
1750 replacement->next = last->next; in _glcpp_parser_evaluate_defined_in_list()
1751 if (last == list->tail) in _glcpp_parser_evaluate_defined_in_list()
1752 list->tail = replacement; in _glcpp_parser_evaluate_defined_in_list()
1754 node = replacement; in _glcpp_parser_evaluate_defined_in_list()
1757 node_prev = node; in _glcpp_parser_evaluate_defined_in_list()
1758 node = node->next; in _glcpp_parser_evaluate_defined_in_list()
1788 token_node_t *node; in _glcpp_parser_apply_pastes() local
1790 node = list->head; in _glcpp_parser_apply_pastes()
1791 while (node) { in _glcpp_parser_apply_pastes()
1795 next_non_space = node->next; in _glcpp_parser_apply_pastes()
1796 while (next_non_space && next_non_space->token->type == SPACE) in _glcpp_parser_apply_pastes()
1797 next_non_space = next_non_space->next; in _glcpp_parser_apply_pastes()
1802 if (next_non_space->token->type != PASTE) { in _glcpp_parser_apply_pastes()
1803 node = next_non_space; in _glcpp_parser_apply_pastes()
1807 /* Now find the next non-space token after the PASTE. */ in _glcpp_parser_apply_pastes()
1808 next_non_space = next_non_space->next; in _glcpp_parser_apply_pastes()
1809 while (next_non_space && next_non_space->token->type == SPACE) in _glcpp_parser_apply_pastes()
1810 next_non_space = next_non_space->next; in _glcpp_parser_apply_pastes()
1813 …yyerror(&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); in _glcpp_parser_apply_pastes()
1817 node->token = _token_paste(parser, node->token, next_non_space->token); in _glcpp_parser_apply_pastes()
1818 node->next = next_non_space->next; in _glcpp_parser_apply_pastes()
1819 if (next_non_space == list->tail) in _glcpp_parser_apply_pastes()
1820 list->tail = node; in _glcpp_parser_apply_pastes()
1823 list->non_space_tail = list->tail; in _glcpp_parser_apply_pastes()
1830 * Returns NULL if node is a simple token with no expansion, (that is,
1831 * although 'node' corresponds to an identifier defined as a
1832 * function-like macro, it is not followed with a parenthesized
1835 * Compute the complete expansion of node (which is a function-like
1839 * *last to the last node in the list that was consumed by the
1847 _glcpp_parser_expand_function(glcpp_parser_t *parser, token_node_t *node, in _glcpp_parser_expand_function() argument
1858 identifier = node->token->value.str; in _glcpp_parser_expand_function()
1860 entry = _mesa_hash_table_search(parser->defines, identifier); in _glcpp_parser_expand_function()
1861 macro = entry ? entry->data : NULL; in _glcpp_parser_expand_function()
1863 assert(macro->is_function); in _glcpp_parser_expand_function()
1866 status = _arguments_parse(parser, arguments, node, last); in _glcpp_parser_expand_function()
1874 …glcpp_error(&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifi… in _glcpp_parser_expand_function()
1879 if (macro->replacements == NULL) { in _glcpp_parser_expand_function()
1884 _string_list_length (macro->parameters)) || in _glcpp_parser_expand_function()
1885 (_string_list_length (macro->parameters) == 0 && in _glcpp_parser_expand_function()
1887 arguments->head->argument->head == NULL))) { in _glcpp_parser_expand_function()
1888 glcpp_error(&node->token->location, parser, in _glcpp_parser_expand_function()
1891 _string_list_length(macro->parameters)); in _glcpp_parser_expand_function()
1898 for (node = macro->replacements->head; node; node = node->next) { in _glcpp_parser_expand_function()
1899 if (node->token->type == IDENTIFIER && in _glcpp_parser_expand_function()
1900 _string_list_contains(macro->parameters, node->token->value.str, in _glcpp_parser_expand_function()
1906 if (argument->head) { in _glcpp_parser_expand_function()
1919 _token_list_append(parser, substituted, node->token); in _glcpp_parser_expand_function()
1933 /* Compute the complete expansion of node, (and subsequent nodes after
1934 * 'node' in the case that 'node' is a function-like macro and
1937 * Returns NULL if node is a simple token with no expansion.
1940 * and sets *last to the last node in the list that was consumed by
1943 * As 'node' in the case of object-like macro expansion.
1946 * function-like macro expansion.
1952 _glcpp_parser_expand_node(glcpp_parser_t *parser, token_node_t *node, in _glcpp_parser_expand_node() argument
1956 token_t *token = node->token; in _glcpp_parser_expand_node()
1962 if (token->type != IDENTIFIER) { in _glcpp_parser_expand_node()
1966 *last = node; in _glcpp_parser_expand_node()
1967 identifier = token->value.str; in _glcpp_parser_expand_node()
1977 node->token->location.source); in _glcpp_parser_expand_node()
1981 entry = _mesa_hash_table_search(parser->defines, identifier); in _glcpp_parser_expand_node()
1982 macro = entry ? entry->data : NULL; in _glcpp_parser_expand_node()
1997 str = linear_strdup(parser->linalloc, token->value.str); in _glcpp_parser_expand_node()
2004 if (! macro->is_function) { in _glcpp_parser_expand_node()
2008 if (macro->replacements == NULL) in _glcpp_parser_expand_node()
2011 replacement = _token_list_copy(parser, macro->replacements); in _glcpp_parser_expand_node()
2016 return _glcpp_parser_expand_function(parser, node, last, mode); in _glcpp_parser_expand_node()
2021 * Here, 'marker' is the token node that appears in the list after the
2023 * examining 'marker', then it is time to pop this node from the
2030 active_list_t *node; in _parser_active_list_push() local
2032 node = linear_alloc_child(parser->linalloc, sizeof(active_list_t)); in _parser_active_list_push()
2033 node->identifier = linear_strdup(parser->linalloc, identifier); in _parser_active_list_push()
2034 node->marker = marker; in _parser_active_list_push()
2035 node->next = parser->active; in _parser_active_list_push()
2037 parser->active = node; in _parser_active_list_push()
2043 active_list_t *node = parser->active; in _parser_active_list_pop() local
2045 if (node == NULL) { in _parser_active_list_pop()
2046 parser->active = NULL; in _parser_active_list_pop()
2050 node = parser->active->next; in _parser_active_list_pop()
2051 parser->active = node; in _parser_active_list_pop()
2057 active_list_t *node; in _parser_active_list_contains() local
2059 if (parser->active == NULL) in _parser_active_list_contains()
2062 for (node = parser->active; node; node = node->next) in _parser_active_list_contains()
2063 if (strcmp(node->identifier, identifier) == 0) in _parser_active_list_contains()
2095 token_node_t *node, *last = NULL; in _glcpp_parser_expand_token_list() local
2097 active_list_t *active_initial = parser->active; in _glcpp_parser_expand_token_list()
2105 line = list->tail->token->location.last_line; in _glcpp_parser_expand_token_list()
2108 node = list->head; in _glcpp_parser_expand_token_list()
2113 while (node) { in _glcpp_parser_expand_token_list()
2115 while (parser->active && parser->active->marker == node) in _glcpp_parser_expand_token_list()
2118 expansion = _glcpp_parser_expand_node (parser, node, &last, mode, line); in _glcpp_parser_expand_token_list()
2126 for (n = node; n != last->next; n = n->next) in _glcpp_parser_expand_token_list()
2127 while (parser->active && parser->active->marker == n) { in _glcpp_parser_expand_token_list()
2131 _parser_active_list_push(parser, node->token->value.str, last->next); in _glcpp_parser_expand_token_list()
2136 if (expansion->head) { in _glcpp_parser_expand_token_list()
2138 node_prev->next = expansion->head; in _glcpp_parser_expand_token_list()
2140 list->head = expansion->head; in _glcpp_parser_expand_token_list()
2141 expansion->tail->next = last->next; in _glcpp_parser_expand_token_list()
2142 if (last == list->tail) in _glcpp_parser_expand_token_list()
2143 list->tail = expansion->tail; in _glcpp_parser_expand_token_list()
2146 node_prev->next = last->next; in _glcpp_parser_expand_token_list()
2148 list->head = last->next; in _glcpp_parser_expand_token_list()
2149 if (last == list->tail) in _glcpp_parser_expand_token_list()
2150 list->tail = NULL; in _glcpp_parser_expand_token_list()
2153 node_prev = node; in _glcpp_parser_expand_token_list()
2155 node = node_prev ? node_prev->next : list->head; in _glcpp_parser_expand_token_list()
2161 while (parser->active && parser->active != active_initial) in _glcpp_parser_expand_token_list()
2164 list->non_space_tail = list->tail; in _glcpp_parser_expand_token_list()
2200 * A future version of the GLSL specification will clarify this. in _check_for_reserved_macro_name()
2217 if (a->is_function != b->is_function) in _macro_equal()
2220 if (a->is_function) { in _macro_equal()
2221 if (! _string_list_equal (a->parameters, b->parameters)) in _macro_equal()
2225 return _token_list_equal_ignoring_space(a->replacements, b->replacements); in _macro_equal()
2235 /* We define pre-defined macros before we've started parsing the actual in _define_object_macro()
2241 macro = linear_alloc_child(parser->linalloc, sizeof(macro_t)); in _define_object_macro()
2243 macro->is_function = 0; in _define_object_macro()
2244 macro->parameters = NULL; in _define_object_macro()
2245 macro->identifier = linear_strdup(parser->linalloc, identifier); in _define_object_macro()
2246 macro->replacements = replacements; in _define_object_macro()
2248 entry = _mesa_hash_table_search(parser->defines, identifier); in _define_object_macro()
2249 previous = entry ? entry->data : NULL; in _define_object_macro()
2257 _mesa_hash_table_insert (parser->defines, identifier, macro); in _define_object_macro()
2276 macro = linear_alloc_child(parser->linalloc, sizeof(macro_t)); in _define_function_macro()
2278 macro->is_function = 1; in _define_function_macro()
2279 macro->parameters = parameters; in _define_function_macro()
2280 macro->identifier = linear_strdup(parser->linalloc, identifier); in _define_function_macro()
2281 macro->replacements = replacements; in _define_function_macro()
2283 entry = _mesa_hash_table_search(parser->defines, identifier); in _define_function_macro()
2284 previous = entry ? entry->data : NULL; in _define_function_macro()
2292 _mesa_hash_table_insert(parser->defines, identifier, macro); in _define_function_macro()
2298 token_node_t *node; in glcpp_parser_lex() local
2301 if (parser->lex_from_list == NULL) { in glcpp_parser_lex()
2302 ret = glcpp_lex(yylval, yylloc, parser->scanner); in glcpp_parser_lex()
2307 * function-like macro name, but have not yet seen its in glcpp_parser_lex()
2311 * mid-rule actions in the grammar. in glcpp_parser_lex()
2316 if (parser->newline_as_space) { in glcpp_parser_lex()
2318 parser->paren_count++; in glcpp_parser_lex()
2320 parser->paren_count--; in glcpp_parser_lex()
2321 if (parser->paren_count == 0) in glcpp_parser_lex()
2322 parser->newline_as_space = 0; in glcpp_parser_lex()
2326 if (parser->paren_count == 0) in glcpp_parser_lex()
2327 parser->newline_as_space = 0; in glcpp_parser_lex()
2329 } else if (parser->in_control_line) { in glcpp_parser_lex()
2331 parser->in_control_line = 0; in glcpp_parser_lex()
2336 parser->in_control_line = 1; in glcpp_parser_lex()
2338 struct hash_entry *entry = _mesa_hash_table_search(parser->defines, in glcpp_parser_lex()
2339 yylval->str); in glcpp_parser_lex()
2340 macro_t *macro = entry ? entry->data : NULL; in glcpp_parser_lex()
2341 if (macro && macro->is_function) { in glcpp_parser_lex()
2342 parser->newline_as_space = 1; in glcpp_parser_lex()
2343 parser->paren_count = 0; in glcpp_parser_lex()
2350 node = parser->lex_from_node; in glcpp_parser_lex()
2352 if (node == NULL) { in glcpp_parser_lex()
2353 parser->lex_from_list = NULL; in glcpp_parser_lex()
2357 *yylval = node->token->value; in glcpp_parser_lex()
2358 ret = node->token->type; in glcpp_parser_lex()
2360 parser->lex_from_node = node->next; in glcpp_parser_lex()
2368 token_node_t *node; in glcpp_parser_lex_from() local
2370 assert (parser->lex_from_list == NULL); in glcpp_parser_lex_from()
2373 parser->lex_from_list = _token_list_create (parser); in glcpp_parser_lex_from()
2375 for (node = list->head; node; node = node->next) { in glcpp_parser_lex_from()
2376 if (node->token->type == SPACE) in glcpp_parser_lex_from()
2378 _token_list_append (parser, parser->lex_from_list, node->token); in glcpp_parser_lex_from()
2381 parser->lex_from_node = parser->lex_from_list->head; in glcpp_parser_lex_from()
2384 if (parser->lex_from_node == NULL) { in glcpp_parser_lex_from()
2385 parser->lex_from_list = NULL; in glcpp_parser_lex_from()
2394 skip_node_t *node; in _glcpp_parser_skip_stack_push_if() local
2396 if (parser->skip_stack) in _glcpp_parser_skip_stack_push_if()
2397 current = parser->skip_stack->type; in _glcpp_parser_skip_stack_push_if()
2399 node = linear_alloc_child(parser->linalloc, sizeof(skip_node_t)); in _glcpp_parser_skip_stack_push_if()
2400 node->loc = *loc; in _glcpp_parser_skip_stack_push_if()
2404 node->type = SKIP_NO_SKIP; in _glcpp_parser_skip_stack_push_if()
2406 node->type = SKIP_TO_ELSE; in _glcpp_parser_skip_stack_push_if()
2408 node->type = SKIP_TO_ENDIF; in _glcpp_parser_skip_stack_push_if()
2411 node->has_else = false; in _glcpp_parser_skip_stack_push_if()
2412 node->next = parser->skip_stack; in _glcpp_parser_skip_stack_push_if()
2413 parser->skip_stack = node; in _glcpp_parser_skip_stack_push_if()
2420 if (parser->skip_stack == NULL) { in _glcpp_parser_skip_stack_change_if()
2425 if (parser->skip_stack->type == SKIP_TO_ELSE) { in _glcpp_parser_skip_stack_change_if()
2427 parser->skip_stack->type = SKIP_NO_SKIP; in _glcpp_parser_skip_stack_change_if()
2429 parser->skip_stack->type = SKIP_TO_ENDIF; in _glcpp_parser_skip_stack_change_if()
2436 skip_node_t *node; in _glcpp_parser_skip_stack_pop() local
2438 if (parser->skip_stack == NULL) { in _glcpp_parser_skip_stack_pop()
2443 node = parser->skip_stack; in _glcpp_parser_skip_stack_pop()
2444 parser->skip_stack = node->next; in _glcpp_parser_skip_stack_pop()
2448 _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version, in _glcpp_parser_handle_version_declaration() argument
2452 if (parser->version_set) in _glcpp_parser_handle_version_declaration()
2455 parser->version = version; in _glcpp_parser_handle_version_declaration()
2456 parser->version_set = true; in _glcpp_parser_handle_version_declaration()
2458 add_builtin_define (parser, "__VERSION__", version); in _glcpp_parser_handle_version_declaration()
2460 parser->is_gles = (version == 100) || in _glcpp_parser_handle_version_declaration()
2462 bool is_compat = version >= 150 && identifier && in _glcpp_parser_handle_version_declaration()
2465 /* Add pre-defined macros. */ in _glcpp_parser_handle_version_declaration()
2466 if (parser->is_gles) in _glcpp_parser_handle_version_declaration()
2470 else if (version >= 150) in _glcpp_parser_handle_version_declaration()
2478 if (version >= 130 || parser->is_gles) in _glcpp_parser_handle_version_declaration()
2482 if (parser->extensions) in _glcpp_parser_handle_version_declaration()
2483 parser->extensions(parser->state, add_builtin_define, parser, in _glcpp_parser_handle_version_declaration()
2484 version, parser->is_gles); in _glcpp_parser_handle_version_declaration()
2486 if (parser->extension_list) { in _glcpp_parser_handle_version_declaration()
2491 if (parser->extension_list->MESA_shader_integer_functions) { in _glcpp_parser_handle_version_declaration()
2502 _mesa_string_buffer_printf(parser->output, in _glcpp_parser_handle_version_declaration()
2503 "#version %" PRIiMAX "%s%s", version, in _glcpp_parser_handle_version_declaration()
2509 /* GLSL version if no version is explicitly specified. */
2512 /* GLSL ES version if no version is explicitly specified. */
2518 int language_version = parser->api == API_OPENGLES2 ? in glcpp_parser_resolve_implicit_version()
2532 if (di->parser->error) in glcpp_parser_copy_defines()
2535 const char *identifier = macro->identifier; in glcpp_parser_copy_defines()
2536 struct hash_entry *entry = _mesa_hash_table_search(di->parser->defines, in glcpp_parser_copy_defines()
2539 macro_t *previous = entry ? entry->data : NULL; in glcpp_parser_copy_defines()
2544 glcpp_error(di->loc, di->parser, "Redefinition of macro %s\n", in glcpp_parser_copy_defines()
2548 _mesa_hash_table_insert(di->parser->defines, identifier, macro); in glcpp_parser_copy_defines()