ReactOS  0.4.14-dev-50-g13bb5e2
hlsl.tab.c
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 3.0. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34  simplifying the original so-called "semantic" parser. */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37  infringing on user name space. This should be done even for local
38  variables, as they might otherwise be expanded by user macros.
39  There are some unavoidable exceptions within include files to
40  define necessary library symbols; they are noted "INFRINGES ON
41  USER NAME SPACE" below. */
42 
43 /* Identify Bison output. */
44 #define YYBISON 1
45 
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0"
48 
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers. */
53 #define YYPURE 0
54 
55 /* Push parsers. */
56 #define YYPUSH 0
57 
58 /* Pull parsers. */
59 #define YYPULL 1
60 
61 
62 /* Substitute the variable and function names. */
63 #define yyparse hlsl_parse
64 #define yylex hlsl_lex
65 #define yyerror hlsl_error
66 #define yydebug hlsl_debug
67 #define yynerrs hlsl_nerrs
68 
69 #define yylval hlsl_lval
70 #define yychar hlsl_char
71 #define yylloc hlsl_lloc
72 
73 /* Copy the first part of user declarations. */
74 #line 21 "hlsl.y" /* yacc.c:339 */
75 
76 #include "config.h"
77 #include "wine/debug.h"
78 
79 #include <stdio.h>
80 
81 #include "d3dcompiler_private.h"
82 
83 WINE_DEFAULT_DEBUG_CHANNEL(hlsl_parser);
84 
85 int hlsl_lex(void);
86 
88 
89 struct YYLTYPE;
90 static void set_location(struct source_location *loc, const struct YYLTYPE *l);
91 
92 void hlsl_message(const char *fmt, ...)
93 {
94  va_list args;
95 
96  va_start(args, fmt);
97  compilation_message(&hlsl_ctx.messages, fmt, args);
98  va_end(args);
99 }
100 
102 {
103  static const char * const names[] =
104  {
105  "error",
106  "warning",
107  "note",
108  };
109  return names[level];
110 }
111 
113  enum hlsl_error_level level, const char *fmt, ...)
114 {
115  va_list args;
116  char *string = NULL;
117  int rc, size = 0;
118 
119  while (1)
120  {
121  va_start(args, fmt);
122  rc = vsnprintf(string, size, fmt, args);
123  va_end(args);
124 
125  if (rc >= 0 && rc < size)
126  break;
127 
128  if (rc >= size)
129  size = rc + 1;
130  else
131  size = size ? size * 2 : 32;
132 
133  if (!string)
134  string = d3dcompiler_alloc(size);
135  else
136  string = d3dcompiler_realloc(string, size);
137  if (!string)
138  {
139  ERR("Error reallocating memory for a string.\n");
140  return;
141  }
142  }
143 
144  hlsl_message("%s:%u:%u: %s: %s\n", filename, line, column, hlsl_get_error_level_name(level), string);
145  d3dcompiler_free(string);
146 
147  if (level == HLSL_LEVEL_ERROR)
149  else if (level == HLSL_LEVEL_WARNING)
151 }
152 
153 static void hlsl_error(const char *s)
154 {
155  hlsl_report_message(hlsl_ctx.source_file, hlsl_ctx.line_no, hlsl_ctx.column, HLSL_LEVEL_ERROR, "%s", s);
156 }
157 
158 static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char *declname, unsigned int line_no)
159 {
160  TRACE("Line %u: ", line_no);
161  if (modifiers)
162  TRACE("%s ", debug_modifiers(modifiers));
163  TRACE("%s %s;\n", debug_hlsl_type(type), declname);
164 }
165 
166 static void check_invalid_matrix_modifiers(DWORD modifiers, struct source_location *loc)
167 {
169  {
171  "'row_major' or 'column_major' modifiers are only allowed for matrices");
172  }
173 }
174 
176 {
177  BOOL ret;
178 
179  TRACE("Declaring variable %s.\n", decl->name);
180  if (decl->node.data_type->type == HLSL_CLASS_MATRIX)
181  {
183  {
184  decl->modifiers |= hlsl_ctx.matrix_majority == HLSL_ROW_MAJOR
186  }
187  }
188  else
189  check_invalid_matrix_modifiers(decl->modifiers, &decl->node.loc);
190 
191  if (local)
192  {
195  if (invalid)
196  {
197  hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
198  "modifier '%s' invalid for local variables", debug_modifiers(invalid));
199  }
200  if (decl->semantic)
201  {
202  hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
203  "semantics are not allowed on local variables");
204  return FALSE;
205  }
206  }
207  else
208  {
209  if (find_function(decl->name))
210  {
211  hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
212  "redefinition of '%s'", decl->name);
213  return FALSE;
214  }
215  }
216  ret = add_declaration(hlsl_ctx.cur_scope, decl, local);
217  if (!ret)
218  {
219  struct hlsl_ir_var *old = get_variable(hlsl_ctx.cur_scope, decl->name);
220 
221  hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR,
222  "\"%s\" already declared", decl->name);
223  hlsl_report_message(old->node.loc.file, old->node.loc.line, old->node.loc.col, HLSL_LEVEL_NOTE,
224  "\"%s\" was previously declared here", old->name);
225  return FALSE;
226  }
227  return TRUE;
228 }
229 
230 static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc);
231 
233 {
235  {
237  "modifier not allowed on typedefs");
238  return FALSE;
239  }
240  return TRUE;
241 }
242 
243 static BOOL add_type_to_scope(struct hlsl_scope *scope, struct hlsl_type *def)
244 {
245  if (get_type(scope, def->name, FALSE))
246  return FALSE;
247 
248  wine_rb_put(&scope->types, def->name, &def->scope_entry);
249  return TRUE;
250 }
251 
252 static void declare_predefined_types(struct hlsl_scope *scope)
253 {
254  struct hlsl_type *type;
255  unsigned int x, y, bt;
256  static const char * const names[] =
257  {
258  "float",
259  "half",
260  "double",
261  "int",
262  "uint",
263  "bool",
264  };
265  char name[10];
266 
267  for (bt = 0; bt <= HLSL_TYPE_LAST_SCALAR; ++bt)
268  {
269  for (y = 1; y <= 4; ++y)
270  {
271  for (x = 1; x <= 4; ++x)
272  {
273  sprintf(name, "%s%ux%u", names[bt], x, y);
275  add_type_to_scope(scope, type);
276 
277  if (y == 1)
278  {
279  sprintf(name, "%s%u", names[bt], x);
281  add_type_to_scope(scope, type);
282 
283  if (x == 1)
284  {
285  sprintf(name, "%s", names[bt]);
287  add_type_to_scope(scope, type);
288  }
289  }
290  }
291  }
292  }
293 
294  /* DX8 effects predefined types */
296  add_type_to_scope(scope, type);
298  add_type_to_scope(scope, type);
300  add_type_to_scope(scope, type);
302  add_type_to_scope(scope, type);
304  add_type_to_scope(scope, type);
306  add_type_to_scope(scope, type);
308  add_type_to_scope(scope, type);
310  add_type_to_scope(scope, type);
311 }
312 
313 static struct hlsl_ir_if *loop_condition(struct list *cond_list)
314 {
315  struct hlsl_ir_if *out_cond;
316  struct hlsl_ir_expr *not_cond;
317  struct hlsl_ir_node *cond, *operands[3];
318  struct hlsl_ir_jump *jump;
319  unsigned int count = list_count(cond_list);
320 
321  if (!count)
322  return NULL;
323  if (count != 1)
324  ERR("Got multiple expressions in a for condition.\n");
325 
326  cond = LIST_ENTRY(list_head(cond_list), struct hlsl_ir_node, entry);
327  out_cond = d3dcompiler_alloc(sizeof(*out_cond));
328  if (!out_cond)
329  {
330  ERR("Out of memory.\n");
331  return NULL;
332  }
333  out_cond->node.type = HLSL_IR_IF;
334  operands[0] = cond;
335  operands[1] = operands[2] = NULL;
336  not_cond = new_expr(HLSL_IR_UNOP_LOGIC_NOT, operands, &cond->loc);
337  if (!not_cond)
338  {
339  ERR("Out of memory.\n");
340  d3dcompiler_free(out_cond);
341  return NULL;
342  }
343  out_cond->condition = &not_cond->node;
344  jump = d3dcompiler_alloc(sizeof(*jump));
345  if (!jump)
346  {
347  ERR("Out of memory.\n");
348  d3dcompiler_free(out_cond);
349  d3dcompiler_free(not_cond);
350  return NULL;
351  }
352  jump->node.type = HLSL_IR_JUMP;
353  jump->type = HLSL_IR_JUMP_BREAK;
354  out_cond->then_instrs = d3dcompiler_alloc(sizeof(*out_cond->then_instrs));
355  if (!out_cond->then_instrs)
356  {
357  ERR("Out of memory.\n");
358  d3dcompiler_free(out_cond);
359  d3dcompiler_free(not_cond);
360  d3dcompiler_free(jump);
361  return NULL;
362  }
363  list_init(out_cond->then_instrs);
364  list_add_head(out_cond->then_instrs, &jump->node.entry);
365 
366  return out_cond;
367 }
368 
370 {
374 };
375 
376 static struct list *create_loop(enum loop_type type, struct list *init, struct list *cond,
377  struct hlsl_ir_node *iter, struct list *body, struct source_location *loc)
378 {
379  struct list *list = NULL;
380  struct hlsl_ir_loop *loop = NULL;
381  struct hlsl_ir_if *cond_jump = NULL;
382 
383  list = d3dcompiler_alloc(sizeof(*list));
384  if (!list)
385  goto oom;
386  list_init(list);
387 
388  if (init)
390 
391  loop = d3dcompiler_alloc(sizeof(*loop));
392  if (!loop)
393  goto oom;
394  loop->node.type = HLSL_IR_LOOP;
395  loop->node.loc = *loc;
396  list_add_tail(list, &loop->node.entry);
397  loop->body = d3dcompiler_alloc(sizeof(*loop->body));
398  if (!loop->body)
399  goto oom;
400  list_init(loop->body);
401 
402  cond_jump = loop_condition(cond);
403  if (!cond_jump)
404  goto oom;
405 
406  if (type != LOOP_DO_WHILE)
407  list_add_tail(loop->body, &cond_jump->node.entry);
408 
409  list_move_tail(loop->body, body);
410 
411  if (iter)
412  list_add_tail(loop->body, &iter->entry);
413 
414  if (type == LOOP_DO_WHILE)
415  list_add_tail(loop->body, &cond_jump->node.entry);
416 
418  d3dcompiler_free(cond);
420  return list;
421 
422 oom:
423  ERR("Out of memory.\n");
424  if (loop)
425  d3dcompiler_free(loop->body);
426  d3dcompiler_free(loop);
427  d3dcompiler_free(cond_jump);
430  free_instr_list(cond);
431  free_instr(iter);
433  return NULL;
434 }
435 
436 static unsigned int initializer_size(struct list *initializer)
437 {
438  unsigned int count = 0;
439  struct hlsl_ir_node *node;
440 
441  LIST_FOR_EACH_ENTRY(node, initializer, struct hlsl_ir_node, entry)
442  {
443  count += components_count_type(node->data_type);
444  }
445  TRACE("Initializer size = %u\n", count);
446  return count;
447 }
448 
449 static unsigned int components_count_expr_list(struct list *list)
450 {
451  struct hlsl_ir_node *node;
452  unsigned int count = 0;
453 
455  {
456  count += components_count_type(node->data_type);
457  }
458  return count;
459 }
460 
461 static struct hlsl_ir_swizzle *new_swizzle(DWORD s, unsigned int components,
462  struct hlsl_ir_node *val, struct source_location *loc)
463 {
464  struct hlsl_ir_swizzle *swizzle = d3dcompiler_alloc(sizeof(*swizzle));
465 
466  if (!swizzle)
467  return NULL;
468  swizzle->node.type = HLSL_IR_SWIZZLE;
469  swizzle->node.loc = *loc;
470  swizzle->node.data_type = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, val->data_type->base_type, components, 1);
471  swizzle->val = val;
472  swizzle->swizzle = s;
473  return swizzle;
474 }
475 
476 static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ir_node *value, const char *swizzle,
477  struct source_location *loc)
478 {
479  unsigned int len = strlen(swizzle), component = 0;
480  unsigned int i, set, swiz = 0;
481  BOOL valid;
482 
483  if (value->data_type->type == HLSL_CLASS_MATRIX)
484  {
485  /* Matrix swizzle */
486  BOOL m_swizzle;
487  unsigned int inc, x, y;
488 
489  if (len < 3 || swizzle[0] != '_')
490  return NULL;
491  m_swizzle = swizzle[1] == 'm';
492  inc = m_swizzle ? 4 : 3;
493 
494  if (len % inc || len > inc * 4)
495  return NULL;
496 
497  for (i = 0; i < len; i += inc)
498  {
499  if (swizzle[i] != '_')
500  return NULL;
501  if (m_swizzle)
502  {
503  if (swizzle[i + 1] != 'm')
504  return NULL;
505  x = swizzle[i + 2] - '0';
506  y = swizzle[i + 3] - '0';
507  }
508  else
509  {
510  x = swizzle[i + 1] - '1';
511  y = swizzle[i + 2] - '1';
512  }
513 
514  if (x >= value->data_type->dimx || y >= value->data_type->dimy)
515  return NULL;
516  swiz |= (y << 4 | x) << component * 8;
517  component++;
518  }
519  return new_swizzle(swiz, component, value, loc);
520  }
521 
522  /* Vector swizzle */
523  if (len > 4)
524  return NULL;
525 
526  for (set = 0; set < 2; ++set)
527  {
528  valid = TRUE;
529  component = 0;
530  for (i = 0; i < len; ++i)
531  {
532  char c[2][4] = {{'x', 'y', 'z', 'w'}, {'r', 'g', 'b', 'a'}};
533  unsigned int s = 0;
534 
535  for (s = 0; s < 4; ++s)
536  {
537  if (swizzle[i] == c[set][s])
538  break;
539  }
540  if (s == 4)
541  {
542  valid = FALSE;
543  break;
544  }
545 
546  if (s >= value->data_type->dimx)
547  return NULL;
548  swiz |= s << component * 2;
549  component++;
550  }
551  if (valid)
552  return new_swizzle(swiz, component, value, loc);
553  }
554 
555  return NULL;
556 }
557 
558 static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var, struct list *initializer)
559 {
560  struct hlsl_type *type = var->node.data_type;
561  struct hlsl_ir_node *node;
562  struct hlsl_struct_field *field;
563  struct list *cur_node;
564  struct hlsl_ir_node *assignment;
565  struct hlsl_ir_deref *deref;
566 
567  if (initializer_size(initializer) != components_count_type(type))
568  {
569  hlsl_report_message(var->node.loc.file, var->node.loc.line, var->node.loc.col, HLSL_LEVEL_ERROR,
570  "structure initializer mismatch");
571  free_instr_list(initializer);
572  return;
573  }
574  cur_node = list_head(initializer);
575  assert(cur_node);
576  node = LIST_ENTRY(cur_node, struct hlsl_ir_node, entry);
577  LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
578  {
579  if (!cur_node)
580  {
581  d3dcompiler_free(initializer);
582  return;
583  }
585  {
586  deref = new_record_deref(&var->node, field);
587  if (!deref)
588  {
589  ERR("Out of memory.\n");
590  break;
591  }
592  deref->node.loc = node->loc;
594  list_add_tail(list, &assignment->entry);
595  }
596  else
597  FIXME("Initializing with \"mismatched\" fields is not supported yet.\n");
598  cur_node = list_next(initializer, cur_node);
599  node = LIST_ENTRY(cur_node, struct hlsl_ir_node, entry);
600  }
601 
602  /* Free initializer elements in excess. */
603  while (cur_node)
604  {
605  struct list *next = list_next(initializer, cur_node);
606  free_instr(node);
607  cur_node = next;
608  node = LIST_ENTRY(cur_node, struct hlsl_ir_node, entry);
609  }
610  d3dcompiler_free(initializer);
611 }
612 
613 static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, struct list *var_list)
614 {
615  struct hlsl_type *type;
616  struct parse_variable_def *v, *v_next;
617  struct hlsl_ir_var *var;
618  struct hlsl_ir_node *assignment;
619  BOOL ret, local = TRUE;
620  struct list *statements_list = d3dcompiler_alloc(sizeof(*statements_list));
621 
622  if (!statements_list)
623  {
624  ERR("Out of memory.\n");
625  LIST_FOR_EACH_ENTRY_SAFE(v, v_next, var_list, struct parse_variable_def, entry)
627  d3dcompiler_free(var_list);
628  return NULL;
629  }
630  list_init(statements_list);
631 
632  if (!var_list)
633  return statements_list;
634 
635  LIST_FOR_EACH_ENTRY_SAFE(v, v_next, var_list, struct parse_variable_def, entry)
636  {
637  var = d3dcompiler_alloc(sizeof(*var));
638  if (!var)
639  {
640  ERR("Out of memory.\n");
642  continue;
643  }
644  var->node.type = HLSL_IR_VAR;
645  if (v->array_size)
646  type = new_array_type(basic_type, v->array_size);
647  else
648  type = basic_type;
649  var->node.data_type = type;
650  var->node.loc = v->loc;
651  var->name = v->name;
652  var->modifiers = modifiers;
653  var->semantic = v->semantic;
654  var->reg_reservation = v->reg_reservation;
655  debug_dump_decl(type, modifiers, v->name, v->loc.line);
656 
657  if (hlsl_ctx.cur_scope == hlsl_ctx.globals)
658  {
660  local = FALSE;
661  }
662 
663  if (var->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer)
664  {
665  hlsl_report_message(v->loc.file, v->loc.line, v->loc.col,
666  HLSL_LEVEL_ERROR, "const variable without initializer");
667  free_declaration(var);
669  continue;
670  }
671 
672  ret = declare_variable(var, local);
673  if (!ret)
674  {
675  free_declaration(var);
677  continue;
678  }
679  TRACE("Declared variable %s.\n", var->name);
680 
681  if (v->initializer)
682  {
683  unsigned int size = initializer_size(v->initializer);
684  struct hlsl_ir_node *node;
685 
686  TRACE("Variable with initializer.\n");
687  if (type->type <= HLSL_CLASS_LAST_NUMERIC
688  && type->dimx * type->dimy != size && size != 1)
689  {
690  if (size < type->dimx * type->dimy)
691  {
692  hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
693  "'%s' initializer does not match", v->name);
694  free_instr_list(v->initializer);
696  continue;
697  }
698  }
699  if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY)
701  {
702  hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
703  "'%s' initializer does not match", v->name);
704  free_instr_list(v->initializer);
706  continue;
707  }
708 
709  if (type->type == HLSL_CLASS_STRUCT)
710  {
711  struct_var_initializer(statements_list, var, v->initializer);
713  continue;
714  }
715  if (type->type > HLSL_CLASS_LAST_NUMERIC)
716  {
717  FIXME("Initializers for non scalar/struct variables not supported yet.\n");
718  free_instr_list(v->initializer);
720  continue;
721  }
722  if (v->array_size > 0)
723  {
724  FIXME("Initializing arrays is not supported yet.\n");
725  free_instr_list(v->initializer);
727  continue;
728  }
729  if (list_count(v->initializer) > 1)
730  {
731  FIXME("Complex initializers are not supported yet.\n");
732  free_instr_list(v->initializer);
734  continue;
735  }
736  node = LIST_ENTRY(list_head(v->initializer), struct hlsl_ir_node, entry);
737  assignment = make_assignment(&var->node, ASSIGN_OP_ASSIGN,
739  list_add_tail(statements_list, &assignment->entry);
740  d3dcompiler_free(v->initializer);
741  }
743  }
744  d3dcompiler_free(var_list);
745  return statements_list;
746 }
747 
748 static BOOL add_struct_field(struct list *fields, struct hlsl_struct_field *field)
749 {
750  struct hlsl_struct_field *f;
751 
752  LIST_FOR_EACH_ENTRY(f, fields, struct hlsl_struct_field, entry)
753  {
754  if (!strcmp(f->name, field->name))
755  return FALSE;
756  }
757  list_add_tail(fields, &field->entry);
758  return TRUE;
759 }
760 
761 static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, struct list *fields)
762 {
763  struct parse_variable_def *v, *v_next;
764  struct hlsl_struct_field *field;
765  struct list *list;
766 
767  list = d3dcompiler_alloc(sizeof(*list));
768  if (!list)
769  {
770  ERR("Out of memory.\n");
771  return NULL;
772  }
773  list_init(list);
774  LIST_FOR_EACH_ENTRY_SAFE(v, v_next, fields, struct parse_variable_def, entry)
775  {
776  debug_dump_decl(type, 0, v->name, v->loc.line);
777  field = d3dcompiler_alloc(sizeof(*field));
778  if (!field)
779  {
780  ERR("Out of memory.\n");
782  return list;
783  }
784  field->type = type;
785  field->name = v->name;
786  field->modifiers = modifiers;
787  field->semantic = v->semantic;
788  if (v->initializer)
789  {
790  hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
791  "struct field with an initializer.\n");
792  free_instr_list(v->initializer);
793  }
794  list_add_tail(list, &field->entry);
796  }
797  d3dcompiler_free(fields);
798  return list;
799 }
800 
801 static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, struct list *fields)
802 {
803  struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type));
804 
805  if (!type)
806  {
807  ERR("Out of memory.\n");
808  return NULL;
809  }
810  type->type = HLSL_CLASS_STRUCT;
811  type->name = name;
812  type->dimx = type->dimy = 1;
813  type->modifiers = modifiers;
814  type->e.elements = fields;
815 
816  list_add_tail(&hlsl_ctx.types, &type->entry);
817 
818  return type;
819 }
820 
821 static BOOL add_typedef(DWORD modifiers, struct hlsl_type *orig_type, struct list *list,
822  struct source_location *loc)
823 {
824  BOOL ret;
825  struct hlsl_type *type;
826  struct parse_variable_def *v, *v_next;
827 
828  if (!check_type_modifiers(modifiers, loc))
829  {
833  return FALSE;
834  }
835 
837  {
838  if (v->array_size)
839  type = new_array_type(orig_type, v->array_size);
840  else
841  type = clone_hlsl_type(orig_type);
842  if (!type)
843  {
844  ERR("Out of memory\n");
845  return FALSE;
846  }
847  d3dcompiler_free((void *)type->name);
848  type->name = v->name;
849  type->modifiers |= modifiers;
850 
851  if (type->type != HLSL_CLASS_MATRIX)
852  check_invalid_matrix_modifiers(type->modifiers, &v->loc);
853 
854  ret = add_type_to_scope(hlsl_ctx.cur_scope, type);
855  if (!ret)
856  {
857  hlsl_report_message(v->loc.file, v->loc.line, v->loc.col, HLSL_LEVEL_ERROR,
858  "redefinition of custom type '%s'", v->name);
859  }
861  }
863  return TRUE;
864 }
865 
866 static BOOL add_func_parameter(struct list *list, struct parse_parameter *param, const struct source_location *loc)
867 {
868  struct hlsl_ir_var *decl = d3dcompiler_alloc(sizeof(*decl));
869 
870  if (!decl)
871  {
872  ERR("Out of memory.\n");
873  return FALSE;
874  }
875  decl->node.type = HLSL_IR_VAR;
876  decl->node.data_type = param->type;
877  decl->node.loc = *loc;
878  decl->name = param->name;
879  decl->semantic = param->semantic;
880  decl->reg_reservation = param->reg_reservation;
881  decl->modifiers = param->modifiers;
882 
883  if (!add_declaration(hlsl_ctx.cur_scope, decl, FALSE))
884  {
885  free_declaration(decl);
886  return FALSE;
887  }
888  list_add_tail(list, &decl->node.entry);
889  return TRUE;
890 }
891 
892 static struct reg_reservation *parse_reg_reservation(const char *reg_string)
893 {
894  struct reg_reservation *reg_res;
896  DWORD regnum = 0;
897 
898  switch (reg_string[0])
899  {
900  case 'c':
902  break;
903  case 'i':
905  break;
906  case 'b':
908  break;
909  case 's':
911  break;
912  default:
913  FIXME("Unsupported register type.\n");
914  return NULL;
915  }
916 
917  if (!sscanf(reg_string + 1, "%u", &regnum))
918  {
919  FIXME("Unsupported register reservation syntax.\n");
920  return NULL;
921  }
922 
923  reg_res = d3dcompiler_alloc(sizeof(*reg_res));
924  if (!reg_res)
925  {
926  ERR("Out of memory.\n");
927  return NULL;
928  }
929  reg_res->type = type;
930  reg_res->regnum = regnum;
931  return reg_res;
932 }
933 
935  struct list *params, BOOL exact_signature)
936 {
937  struct hlsl_ir_function *func;
938  struct wine_rb_entry *entry;
939 
941  if (entry)
942  {
944 
945  entry = wine_rb_get(&func->overloads, params);
946  if (!entry)
947  {
948  if (!exact_signature)
949  FIXME("No exact match, search for a compatible overloaded function (if any).\n");
950  return NULL;
951  }
953  }
954  return NULL;
955 }
956 
957 
958 #line 959 "hlsl.tab.c" /* yacc.c:339 */
959 
960 # ifndef YY_NULL
961 # if defined __cplusplus && 201103L <= __cplusplus
962 # define YY_NULL nullptr
963 # else
964 # define YY_NULL 0
965 # endif
966 # endif
967 
968 /* Enabling verbose error messages. */
969 #ifdef YYERROR_VERBOSE
970 # undef YYERROR_VERBOSE
971 # define YYERROR_VERBOSE 1
972 #else
973 # define YYERROR_VERBOSE 1
974 #endif
975 
976 /* In a future release of Bison, this section will be replaced
977  by #include "hlsl.tab.h". */
978 #ifndef YY_HLSL_E_REACTOSSYNC_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED
979 # define YY_HLSL_E_REACTOSSYNC_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED
980 /* Debug traces. */
981 #ifndef YYDEBUG
982 # define YYDEBUG 0
983 #endif
984 #if YYDEBUG
985 extern int hlsl_debug;
986 #endif
987 
988 /* Token type. */
989 #ifndef YYTOKENTYPE
990 # define YYTOKENTYPE
992  {
994  KW_BREAK = 259,
995  KW_BUFFER = 260,
996  KW_CBUFFER = 261,
998  KW_COMPILE = 263,
999  KW_CONST = 264,
1003  KW_DISCARD = 268,
1004  KW_DO = 269,
1005  KW_DOUBLE = 270,
1006  KW_ELSE = 271,
1007  KW_EXTERN = 272,
1008  KW_FALSE = 273,
1009  KW_FOR = 274,
1012  KW_IF = 277,
1013  KW_IN = 278,
1014  KW_INLINE = 279,
1015  KW_INOUT = 280,
1016  KW_MATRIX = 281,
1019  KW_OUT = 284,
1020  KW_PASS = 285,
1022  KW_PRECISE = 287,
1025  KW_RETURN = 290,
1028  KW_SAMPLER = 293,
1035  KW_SHARED = 300,
1038  KW_STATIC = 303,
1039  KW_STRING = 304,
1040  KW_STRUCT = 305,
1041  KW_SWITCH = 306,
1042  KW_TBUFFER = 307,
1045  KW_TEXTURE = 310,
1055  KW_TRUE = 320,
1056  KW_TYPEDEF = 321,
1057  KW_UNIFORM = 322,
1058  KW_VECTOR = 323,
1060  KW_VOID = 325,
1062  KW_WHILE = 327,
1063  OP_INC = 328,
1064  OP_DEC = 329,
1065  OP_AND = 330,
1066  OP_OR = 331,
1067  OP_EQ = 332,
1073  OP_LE = 338,
1074  OP_GE = 339,
1075  OP_NE = 340,
1088  PRE_LINE = 353,
1092  STRING = 357,
1093  C_FLOAT = 358,
1095  };
1096 #endif
1097 
1098 /* Value type. */
1099 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1100 typedef union YYSTYPE YYSTYPE;
1101 union YYSTYPE
1102 {
1103 #line 910 "hlsl.y" /* yacc.c:355 */
1104 
1105  struct hlsl_type *type;
1109  char *name;
1111  struct hlsl_ir_var *var;
1113  struct list *list;
1122 
1123 #line 1124 "hlsl.tab.c" /* yacc.c:355 */
1124 };
1125 # define YYSTYPE_IS_TRIVIAL 1
1126 # define YYSTYPE_IS_DECLARED 1
1127 #endif
1128 
1129 /* Location type. */
1130 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
1131 typedef struct YYLTYPE YYLTYPE;
1132 struct YYLTYPE
1133 {
1138 };
1139 # define YYLTYPE_IS_DECLARED 1
1140 # define YYLTYPE_IS_TRIVIAL 1
1141 #endif
1142 
1143 
1144 extern YYSTYPE hlsl_lval;
1145 extern YYLTYPE hlsl_lloc;
1146 int hlsl_parse (void);
1147 
1148 #endif /* !YY_HLSL_E_REACTOSSYNC_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED */
1149 
1150 /* Copy the second part of user declarations. */
1151 
1152 #line 1153 "hlsl.tab.c" /* yacc.c:358 */
1153 
1154 #ifdef short
1155 # undef short
1156 #endif
1157 
1158 #ifdef YYTYPE_UINT8
1159 typedef YYTYPE_UINT8 yytype_uint8;
1160 #else
1161 typedef unsigned char yytype_uint8;
1162 #endif
1163 
1164 #ifdef YYTYPE_INT8
1165 typedef YYTYPE_INT8 yytype_int8;
1166 #else
1167 typedef signed char yytype_int8;
1168 #endif
1169 
1170 #ifdef YYTYPE_UINT16
1171 typedef YYTYPE_UINT16 yytype_uint16;
1172 #else
1173 typedef unsigned short int yytype_uint16;
1174 #endif
1175 
1176 #ifdef YYTYPE_INT16
1177 typedef YYTYPE_INT16 yytype_int16;
1178 #else
1179 typedef short int yytype_int16;
1180 #endif
1181 
1182 #ifndef YYSIZE_T
1183 # ifdef __SIZE_TYPE__
1184 # define YYSIZE_T __SIZE_TYPE__
1185 # elif defined size_t
1186 # define YYSIZE_T size_t
1187 # elif ! defined YYSIZE_T
1188 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1189 # define YYSIZE_T size_t
1190 # else
1191 # define YYSIZE_T unsigned int
1192 # endif
1193 #endif
1194 
1195 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1196 
1197 #ifndef YY_
1198 # if defined YYENABLE_NLS && YYENABLE_NLS
1199 # if ENABLE_NLS
1200 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1201 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
1202 # endif
1203 # endif
1204 # ifndef YY_
1205 # define YY_(Msgid) Msgid
1206 # endif
1207 #endif
1208 
1209 #ifndef __attribute__
1210 /* This feature is available in gcc versions 2.5 and later. */
1211 # if (! defined __GNUC__ || __GNUC__ < 2 \
1212  || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
1213 # define __attribute__(Spec) /* empty */
1214 # endif
1215 #endif
1216 
1217 /* Suppress unused-variable warnings by "using" E. */
1218 #if ! defined lint || defined __GNUC__
1219 # define YYUSE(E) ((void) (E))
1220 #else
1221 # define YYUSE(E) /* empty */
1222 #endif
1223 
1224 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
1225 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
1226 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
1227  _Pragma ("GCC diagnostic push") \
1228  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
1229  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1230 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
1231  _Pragma ("GCC diagnostic pop")
1232 #else
1233 # define YY_INITIAL_VALUE(Value) Value
1234 #endif
1235 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1236 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1237 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1238 #endif
1239 #ifndef YY_INITIAL_VALUE
1240 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1241 #endif
1242 
1243 
1244 #if ! defined yyoverflow || YYERROR_VERBOSE
1245 
1246 /* The parser invokes alloca or malloc; define the necessary symbols. */
1247 
1248 # ifdef YYSTACK_USE_ALLOCA
1249 # if YYSTACK_USE_ALLOCA
1250 # ifdef __GNUC__
1251 # define YYSTACK_ALLOC __builtin_alloca
1252 # elif defined __BUILTIN_VA_ARG_INCR
1253 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1254 # elif defined _AIX
1255 # define YYSTACK_ALLOC __alloca
1256 # elif defined _MSC_VER
1257 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1258 # define alloca _alloca
1259 # else
1260 # define YYSTACK_ALLOC alloca
1261 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
1262 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1263  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
1264 # ifndef EXIT_SUCCESS
1265 # define EXIT_SUCCESS 0
1266 # endif
1267 # endif
1268 # endif
1269 # endif
1270 # endif
1271 
1272 # ifdef YYSTACK_ALLOC
1273  /* Pacify GCC's 'empty if-body' warning. */
1274 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1275 # ifndef YYSTACK_ALLOC_MAXIMUM
1276  /* The OS might guarantee only one guard page at the bottom of the stack,
1277  and a page size can be as small as 4096 bytes. So we cannot safely
1278  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1279  to allow for a few compiler-allocated temporary stack slots. */
1280 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1281 # endif
1282 # else
1283 # define YYSTACK_ALLOC YYMALLOC
1284 # define YYSTACK_FREE YYFREE
1285 # ifndef YYSTACK_ALLOC_MAXIMUM
1286 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1287 # endif
1288 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
1289  && ! ((defined YYMALLOC || defined malloc) \
1290  && (defined YYFREE || defined free)))
1291 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1292 # ifndef EXIT_SUCCESS
1293 # define EXIT_SUCCESS 0
1294 # endif
1295 # endif
1296 # ifndef YYMALLOC
1297 # define YYMALLOC malloc
1298 # if ! defined malloc && ! defined EXIT_SUCCESS
1299 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1300 # endif
1301 # endif
1302 # ifndef YYFREE
1303 # define YYFREE free
1304 # if ! defined free && ! defined EXIT_SUCCESS
1305 void free (void *); /* INFRINGES ON USER NAME SPACE */
1306 # endif
1307 # endif
1308 # endif
1309 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1310 
1311 
1312 #if (! defined yyoverflow \
1313  && (! defined __cplusplus \
1314  || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
1315  && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1316 
1317 /* A type that is properly aligned for any stack member. */
1318 union yyalloc
1319 {
1323 };
1324 
1325 /* The size of the maximum gap between one aligned stack and the next. */
1326 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1327 
1328 /* The size of an array large to enough to hold all stacks, each with
1329  N elements. */
1330 # define YYSTACK_BYTES(N) \
1331  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
1332  + 2 * YYSTACK_GAP_MAXIMUM)
1333 
1334 # define YYCOPY_NEEDED 1
1335 
1336 /* Relocate STACK from its old location to the new one. The
1337  local variables YYSIZE and YYSTACKSIZE give the old and new number of
1338  elements in the stack, and YYPTR gives the new location of the
1339  stack. Advance YYPTR to a properly aligned location for the next
1340  stack. */
1341 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
1342  do \
1343  { \
1344  YYSIZE_T yynewbytes; \
1345  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
1346  Stack = &yyptr->Stack_alloc; \
1347  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1348  yyptr += yynewbytes / sizeof (*yyptr); \
1349  } \
1350  while (0)
1351 
1352 #endif
1353 
1354 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
1355 /* Copy COUNT objects from SRC to DST. The source and destination do
1356  not overlap. */
1357 # ifndef YYCOPY
1358 # if defined __GNUC__ && 1 < __GNUC__
1359 # define YYCOPY(Dst, Src, Count) \
1360  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
1361 # else
1362 # define YYCOPY(Dst, Src, Count) \
1363  do \
1364  { \
1365  YYSIZE_T yyi; \
1366  for (yyi = 0; yyi < (Count); yyi++) \
1367  (Dst)[yyi] = (Src)[yyi]; \
1368  } \
1369  while (0)
1370 # endif
1371 # endif
1372 #endif /* !YYCOPY_NEEDED */
1373 
1374 /* YYFINAL -- State number of the termination state. */
1375 #define YYFINAL 2
1376 /* YYLAST -- Last index in YYTABLE. */
1377 #define YYLAST 821
1378 
1379 /* YYNTOKENS -- Number of terminals. */
1380 #define YYNTOKENS 129
1381 /* YYNNTS -- Number of nonterminals. */
1382 #define YYNNTS 65
1383 /* YYNRULES -- Number of rules. */
1384 #define YYNRULES 175
1385 /* YYNSTATES -- Number of states. */
1386 #define YYNSTATES 321
1387 
1388 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
1389  by yylex, with out-of-bounds checking. */
1390 #define YYUNDEFTOK 2
1391 #define YYMAXUTOK 359
1392 
1393 #define YYTRANSLATE(YYX) \
1394  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1395 
1396 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
1397  as returned by yylex, without out-of-bounds checking. */
1398 static const yytype_uint8 yytranslate[] =
1399 {
1400  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1401  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1402  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1403  2, 2, 2, 120, 2, 2, 2, 124, 125, 2,
1404  108, 109, 122, 118, 111, 119, 117, 123, 2, 2,
1405  2, 2, 2, 2, 2, 2, 2, 2, 110, 105,
1406  112, 114, 113, 128, 2, 2, 2, 2, 2, 2,
1407  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1408  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1409  2, 115, 2, 116, 126, 2, 2, 2, 2, 2,
1410  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1411  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1412  2, 2, 2, 106, 127, 107, 121, 2, 2, 2,
1413  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1414  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1415  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1416  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1417  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1418  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1419  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1420  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1421  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1422  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1423  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1424  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1425  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1426  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1427  15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1428  25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1429  35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1430  45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1431  55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1432  65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1433  75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1434  85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1435  95, 96, 97, 98, 99, 100, 101, 102, 103, 104
1436 };
1437 
1438 #if YYDEBUG
1439  /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
1440 static const yytype_uint16 yyrline[] =
1441 {
1442  0, 1095, 1095, 1097, 1134, 1138, 1141, 1146, 1168, 1185,
1443  1186, 1188, 1214, 1224, 1225, 1226, 1229, 1233, 1252, 1256,
1444  1261, 1268, 1275, 1305, 1310, 1317, 1321, 1322, 1325, 1329,
1445  1334, 1340, 1346, 1351, 1360, 1365, 1370, 1384, 1398, 1409,
1446  1412, 1423, 1427, 1431, 1436, 1440, 1459, 1479, 1483, 1488,
1447  1493, 1498, 1503, 1508, 1516, 1534, 1535, 1536, 1547, 1555,
1448  1564, 1570, 1576, 1584, 1590, 1593, 1598, 1604, 1610, 1619,
1449  1632, 1635, 1643, 1646, 1650, 1654, 1658, 1662, 1666, 1670,
1450  1674, 1678, 1682, 1686, 1691, 1697, 1701, 1706, 1711, 1717,
1451  1723, 1727, 1732, 1736, 1743, 1744, 1745, 1746, 1747, 1748,
1452  1751, 1774, 1798, 1803, 1809, 1824, 1839, 1847, 1859, 1864,
1453  1872, 1886, 1900, 1914, 1925, 1930, 1944, 1948, 1967, 1986,
1454  2040, 2100, 2136, 2140, 2156, 2172, 2192, 2224, 2228, 2232,
1455  2236, 2241, 2245, 2252, 2259, 2267, 2271, 2278, 2286, 2290,
1456  2294, 2299, 2303, 2310, 2317, 2324, 2332, 2336, 2343, 2351,
1457  2355, 2360, 2364, 2369, 2373, 2378, 2382, 2387, 2391, 2396,
1458  2400, 2405, 2409, 2426, 2430, 2434, 2438, 2442, 2446, 2450,
1459  2454, 2458, 2462, 2466, 2471, 2475
1460 };
1461 #endif
1462 
1463 #if YYDEBUG || YYERROR_VERBOSE || 1
1464 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1465  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1466 static const char *const yytname[] =
1467 {
1468  "$end", "error", "$undefined", "KW_BLENDSTATE", "KW_BREAK", "KW_BUFFER",
1469  "KW_CBUFFER", "KW_COLUMN_MAJOR", "KW_COMPILE", "KW_CONST", "KW_CONTINUE",
1470  "KW_DEPTHSTENCILSTATE", "KW_DEPTHSTENCILVIEW", "KW_DISCARD", "KW_DO",
1471  "KW_DOUBLE", "KW_ELSE", "KW_EXTERN", "KW_FALSE", "KW_FOR",
1472  "KW_GEOMETRYSHADER", "KW_GROUPSHARED", "KW_IF", "KW_IN", "KW_INLINE",
1473  "KW_INOUT", "KW_MATRIX", "KW_NAMESPACE", "KW_NOINTERPOLATION", "KW_OUT",
1474  "KW_PASS", "KW_PIXELSHADER", "KW_PRECISE", "KW_RASTERIZERSTATE",
1475  "KW_RENDERTARGETVIEW", "KW_RETURN", "KW_REGISTER", "KW_ROW_MAJOR",
1476  "KW_SAMPLER", "KW_SAMPLER1D", "KW_SAMPLER2D", "KW_SAMPLER3D",
1477  "KW_SAMPLERCUBE", "KW_SAMPLER_STATE", "KW_SAMPLERCOMPARISONSTATE",
1478  "KW_SHARED", "KW_STATEBLOCK", "KW_STATEBLOCK_STATE", "KW_STATIC",
1479  "KW_STRING", "KW_STRUCT", "KW_SWITCH", "KW_TBUFFER", "KW_TECHNIQUE",
1480  "KW_TECHNIQUE10", "KW_TEXTURE", "KW_TEXTURE1D", "KW_TEXTURE1DARRAY",
1481  "KW_TEXTURE2D", "KW_TEXTURE2DARRAY", "KW_TEXTURE2DMS",
1482  "KW_TEXTURE2DMSARRAY", "KW_TEXTURE3D", "KW_TEXTURE3DARRAY",
1483  "KW_TEXTURECUBE", "KW_TRUE", "KW_TYPEDEF", "KW_UNIFORM", "KW_VECTOR",
1484  "KW_VERTEXSHADER", "KW_VOID", "KW_VOLATILE", "KW_WHILE", "OP_INC",
1485  "OP_DEC", "OP_AND", "OP_OR", "OP_EQ", "OP_LEFTSHIFT",
1486  "OP_LEFTSHIFTASSIGN", "OP_RIGHTSHIFT", "OP_RIGHTSHIFTASSIGN",
1487  "OP_ELLIPSIS", "OP_LE", "OP_GE", "OP_NE", "OP_ADDASSIGN", "OP_SUBASSIGN",
1488  "OP_MULASSIGN", "OP_DIVASSIGN", "OP_MODASSIGN", "OP_ANDASSIGN",
1489  "OP_ORASSIGN", "OP_XORASSIGN", "OP_UNKNOWN1", "OP_UNKNOWN2",
1490  "OP_UNKNOWN3", "OP_UNKNOWN4", "PRE_LINE", "VAR_IDENTIFIER",
1491  "TYPE_IDENTIFIER", "NEW_IDENTIFIER", "STRING", "C_FLOAT", "C_INTEGER",
1492  "';'", "'{'", "'}'", "'('", "')'", "':'", "','", "'<'", "'>'", "'='",
1493  "'['", "']'", "'.'", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'",
1494  "'&'", "'^'", "'|'", "'?'", "$accept", "hlsl_prog", "preproc_directive",
1495  "struct_declaration", "struct_spec", "named_struct_spec",
1496  "unnamed_struct_spec", "any_identifier", "fields_list", "field",
1497  "func_declaration", "func_prototype", "compound_statement",
1498  "scope_start", "var_identifier", "colon_attribute", "semantic",
1499  "register_opt", "parameters", "param_list", "parameter", "input_mods",
1500  "input_mod", "type", "base_type", "declaration_statement", "typedef",
1501  "type_specs", "type_spec", "declaration", "variables_def_optional",
1502  "variables_def", "variable_def", "array", "var_modifiers",
1503  "complex_initializer", "initializer_expr", "initializer_expr_list",
1504  "boolean", "statement_list", "statement", "jump_statement",
1505  "selection_statement", "if_body", "loop_statement", "expr_statement",
1506  "primary_expr", "variable", "postfix_expr", "unary_expr", "unary_op",
1507  "mul_expr", "add_expr", "shift_expr", "relational_expr", "equality_expr",
1508  "bitand_expr", "bitxor_expr", "bitor_expr", "logicand_expr",
1509  "logicor_expr", "conditional_expr", "assignment_expr", "assign_op",
1510  "expr", YY_NULL
1511 };
1512 #endif
1513 
1514 # ifdef YYPRINT
1515 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
1516  (internal) symbol number NUM (which must be that of a token). */
1517 static const yytype_uint16 yytoknum[] =
1518 {
1519  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1520  265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1521  275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1522  285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1523  295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1524  305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1525  315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1526  325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1527  335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1528  345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1529  355, 356, 357, 358, 359, 59, 123, 125, 40, 41,
1530  58, 44, 60, 62, 61, 91, 93, 46, 43, 45,
1531  33, 126, 42, 47, 37, 38, 94, 124, 63
1532 };
1533 # endif
1534 
1535 #define YYPACT_NINF -237
1536 
1537 #define yypact_value_is_default(Yystate) \
1538  (!!((Yystate) == (-237)))
1539 
1540 #define YYTABLE_NINF -35
1541 
1542 #define yytable_value_is_error(Yytable_value) \
1543  0
1544 
1545  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1546  STATE-NUM. */
1547 static const yytype_int16 yypact[] =
1548 {
1549  -237, 674, -237, 750, 750, 750, 750, 750, 750, 750,
1550  750, 750, 750, 750, 750, -50, -237, -237, -237, 100,
1551  -237, -237, -237, -78, -237, -237, -237, 39, -237, -237,
1552  -237, -237, -237, -237, -237, -237, -237, 100, 39, -237,
1553  -237, -237, -237, -237, -237, -54, 0, -42, -237, -237,
1554  3, -237, -10, -237, -237, -237, -237, -237, 13, 6,
1555  -237, -237, 121, -237, -54, -5, -237, 100, 613, 5,
1556  -237, 100, -237, 354, 134, 18, -237, 30, 134, 36,
1557  70, 115, 15, -237, -237, 100, 17, -237, -237, 613,
1558  613, -237, -237, -237, 613, -237, -237, -237, -237, 258,
1559  -237, -237, -237, -16, 138, 613, 116, -34, -37, -49,
1560  -38, 64, 106, 67, 161, -55, -237, -237, -57, -3,
1561  130, -237, -237, -237, 354, 153, 168, 613, 174, -237,
1562  -237, -237, 39, 246, -237, -237, -237, -237, -237, 20,
1563  156, 137, 23, -237, 158, -237, -237, -237, -237, -237,
1564  -237, 258, 81, 177, -237, -237, 613, 100, -237, -237,
1565  -237, -237, -237, -237, -237, -237, -237, -237, -237, 613,
1566  -237, 613, 613, 613, 613, 613, 613, 613, 613, 613,
1567  613, 613, 613, 613, 613, 613, 613, 613, 613, 613,
1568  613, -237, 178, -237, 433, 215, -237, 613, 22, 613,
1569  -63, -237, -237, -237, -237, 184, -237, 100, -237, 366,
1570  170, 185, 181, 183, -62, -237, 613, -8, -237, -237,
1571  -237, -237, -237, -237, 116, 116, -34, -34, -37, -37,
1572  -37, -37, -49, -49, -38, 64, 106, 67, 161, 60,
1573  -237, 100, 613, -237, -237, -237, 187, 473, 86, -237,
1574  99, 182, 24, -44, 100, -237, 188, 191, -237, 721,
1575  5, 194, -237, 124, -237, 613, 136, -19, 613, 473,
1576  258, 473, 354, 354, 200, -237, 29, -237, -237, -237,
1577  -237, -237, -237, 258, -237, 613, -237, 613, -237, -237,
1578  100, -237, 552, 140, 613, 613, 289, -237, -237, 193,
1579  -237, -237, 100, -237, -237, 198, -237, 205, 148, 164,
1580  354, -237, 5, -237, -237, 354, 354, -237, -237, -237,
1581  -237
1582 };
1583 
1584  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
1585  Performed when YYTABLE does not specify something else to do. Zero
1586  means the default is an error. */
1587 static const yytype_uint8 yydefact[] =
1588 {
1589  2, 72, 1, 72, 72, 72, 72, 72, 72, 72,
1590  72, 72, 72, 72, 72, 0, 6, 5, 56, 64,
1591  9, 10, 3, 0, 4, 57, 55, 0, 83, 81,
1592  73, 77, 74, 75, 82, 76, 78, 0, 0, 79,
1593  80, 7, 13, 14, 15, 70, 0, 65, 66, 21,
1594  25, 20, 0, 48, 49, 50, 51, 52, 0, 0,
1595  47, 53, 0, 44, 70, 0, 60, 0, 72, 28,
1596  8, 0, 23, 72, 0, 54, 16, 0, 0, 13,
1597  15, 0, 0, 62, 59, 0, 0, 91, 90, 72,
1598  72, 115, 110, 111, 72, 127, 128, 129, 130, 0,
1599  112, 116, 113, 122, 131, 72, 135, 138, 141, 146,
1600  149, 151, 153, 155, 157, 159, 161, 174, 0, 0,
1601  68, 29, 30, 67, 72, 0, 0, 72, 0, 108,
1602  96, 94, 0, 72, 92, 97, 98, 99, 95, 0,
1603  0, 0, 72, 16, 0, 25, 63, 61, 58, 123,
1604  124, 0, 0, 0, 117, 118, 72, 0, 169, 170,
1605  164, 165, 166, 167, 168, 171, 172, 173, 163, 72,
1606  125, 72, 72, 72, 72, 72, 72, 72, 72, 72,
1607  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
1608  72, 71, 0, 31, 72, 0, 25, 72, 0, 72,
1609  0, 24, 93, 109, 54, 0, 12, 0, 17, 0,
1610  72, 0, 39, 0, 70, 114, 72, 0, 119, 162,
1611  132, 133, 134, 131, 136, 137, 139, 140, 144, 145,
1612  142, 143, 147, 148, 150, 152, 154, 156, 158, 0,
1613  175, 0, 72, 69, 84, 87, 0, 72, 0, 100,
1614  0, 0, 0, 0, 0, 11, 0, 35, 36, 72,
1615  28, 0, 88, 0, 120, 72, 0, 0, 72, 72,
1616  0, 72, 72, 72, 0, 19, 0, 45, 39, 41,
1617  43, 42, 40, 0, 22, 72, 121, 72, 160, 32,
1618  0, 85, 72, 0, 72, 72, 102, 101, 104, 0,
1619  18, 37, 0, 126, 89, 0, 86, 0, 0, 0,
1620  72, 46, 28, 33, 105, 72, 72, 103, 38, 107,
1621  106
1622 };
1623 
1624  /* YYPGOTO[NTERM-NUM]. */
1625 static const yytype_int16 yypgoto[] =
1626 {
1627  -237, -237, -237, -237, 304, -237, -123, -36, 179, -237,
1628  -237, -237, 298, -122, -237, -236, -237, -237, -237, -237,
1629  45, -237, -237, -13, 68, 323, -237, 260, 240, 82,
1630  -237, -4, 259, -47, -1, -237, -176, 89, -237, -237,
1631  -104, -237, -237, -237, -237, -221, -237, -237, -237, -23,
1632  -237, 11, 37, 2, 97, 149, 147, 150, 151, 146,
1633  -237, -237, -99, -237, -52
1634 };
1635 
1636  /* YYDEFGOTO[NTERM-NUM]. */
1637 static const yytype_int16 yydefgoto[] =
1638 {
1639  -1, 1, 17, 18, 19, 20, 21, 45, 142, 208,
1640  22, 23, 130, 73, 81, 120, 121, 122, 213, 257,
1641  258, 259, 282, 200, 63, 131, 25, 65, 66, 26,
1642  46, 82, 48, 69, 99, 243, 262, 263, 100, 133,
1643  134, 135, 136, 297, 137, 138, 101, 102, 103, 104,
1644  105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1645  115, 116, 117, 169, 139
1646 };
1647 
1648  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
1649  positive, shift that token. If negative, reduce the rule whose
1650  number is the opposite. If YYTABLE_NINF, syntax error. */
1651 static const yytype_int16 yytable[] =
1652 {
1653  27, 64, 28, 29, 30, 31, 32, 33, 34, 35,
1654  36, 38, 39, 40, 62, 47, 118, 83, 244, 207,
1655  195, 188, 77, 212, 284, 67, 271, 49, 50, 202,
1656  3, 64, 4, 192, 178, 179, 42, 43, 44, 182,
1657  5, 176, 152, 177, 6, 216, 216, 183, 294, 64,
1658  295, 7, 41, 68, 190, 8, 204, 154, 155, 191,
1659  9, 68, 76, 180, 181, 52, 149, 150, 10, 71,
1660  219, 11, 132, 189, 247, 198, 318, 53, 54, 55,
1661  56, 57, 170, 193, 174, 175, 153, 207, 291, 58,
1662  13, 240, 292, 151, 14, 245, 42, 43, 44, 156,
1663  84, 157, 74, 190, 217, 70, 85, 59, 264, 60,
1664  72, 304, 42, 75, 44, 119, 304, 245, 78, 76,
1665  146, 218, 148, 132, -14, 203, 71, 249, 85, 275,
1666  206, 190, 132, 190, 300, 71, 143, 239, 214, 61,
1667  71, 209, 141, 245, -26, 248, 144, 250, 220, 221,
1668  222, 223, 223, 223, 223, 223, 223, 223, 223, 223,
1669  223, 223, 223, 223, 223, 223, 288, 261, 296, 298,
1670  265, 190, 53, 54, 55, 56, 57, 3, -27, 4,
1671  228, 229, 230, 231, 140, 224, 225, 5, 245, 184,
1672  215, 6, 190, 245, 186, 272, 254, 190, 7, 42,
1673  43, 44, 8, 252, 60, 266, 317, 9, 273, 209,
1674  190, 319, 320, 226, 227, 10, 293, 158, 11, 159,
1675  79, 43, 80, 145, 160, 161, 162, 163, 164, 165,
1676  166, 167, 185, 286, 61, 287, 187, 13, 171, 172,
1677  173, 14, 308, 309, 194, 289, 270, 290, 205, 307,
1678  276, 190, 168, 3, 305, 4, 204, 315, 283, 190,
1679  124, 196, 303, 5, 87, 125, 312, 6, 126, 211,
1680  302, 132, 132, 316, 7, 190, 197, 255, 8, 232,
1681  233, 127, 199, 9, 52, 216, 241, 246, 251, 256,
1682  -34, 10, 260, 274, 11, 268, 53, 54, 55, 56,
1683  57, 277, 278, 285, 299, 310, 311, 313, 140, 132,
1684  314, 88, 12, 13, 132, 132, 37, 14, 128, 89,
1685  90, 51, 210, 301, 24, 147, 59, 86, 60, 269,
1686  123, 267, 235, 234, 238, 0, 236, 0, 237, 0,
1687  0, 0, 0, 0, 0, 91, 0, 0, 0, 92,
1688  93, 129, 50, 201, 94, 0, 0, 0, 61, 0,
1689  0, 3, 0, 4, 95, 96, 97, 98, 124, 0,
1690  0, 5, 87, 125, 0, 6, 126, 0, 0, 0,
1691  0, 0, 7, 0, 0, 0, 8, 0, 0, 127,
1692  0, 9, 52, 0, 0, 0, 0, 0, 0, 10,
1693  0, 0, 11, 0, 53, 54, 55, 56, 57, 0,
1694  0, 0, 0, 0, 0, 0, 253, 0, 0, 88,
1695  12, 13, 0, 0, 0, 14, 128, 89, 90, 0,
1696  0, 0, 0, 0, 59, 0, 60, 0, 0, 0,
1697  3, 0, 4, 0, 0, 0, 0, 0, 0, 0,
1698  5, 87, 0, 91, 6, 0, 0, 92, 93, 129,
1699  50, 7, 94, 0, 0, 8, 61, 0, 0, 0,
1700  9, 0, 95, 96, 97, 98, 0, 0, 10, 0,
1701  3, 11, 4, 0, 0, 0, 0, 0, 0, 0,
1702  5, 87, 0, 0, 6, 0, 0, 0, 88, 0,
1703  13, 7, 0, 0, 14, 8, 89, 90, 0, 0,
1704  9, 0, 0, 0, 0, 0, 0, 0, 10, 0,
1705  0, 11, 0, 0, 0, 0, 0, 0, 0, 0,
1706  0, 0, 91, 0, 0, 0, 92, 93, 88, 242,
1707  13, 94, 0, 0, 14, 0, 89, 90, 0, 0,
1708  0, 95, 96, 97, 98, 0, 0, 0, 0, 3,
1709  0, 4, 0, 0, 0, 0, 0, 0, 0, 5,
1710  87, 0, 91, 6, 0, 0, 92, 93, 129, 0,
1711  7, 94, 0, 0, 8, 0, 0, 0, 0, 9,
1712  0, 95, 96, 97, 98, 0, 0, 10, 0, 0,
1713  11, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1714  0, 0, 0, 0, 0, 0, 0, 88, 0, 13,
1715  3, 0, 4, 14, 0, 89, 90, 0, 0, 0,
1716  5, 87, 0, 0, 6, 0, 0, 0, 0, 0,
1717  0, 7, 0, 0, 0, 8, 0, 0, 0, 0,
1718  9, 91, 0, 0, 0, 92, 93, 0, 10, 306,
1719  94, 11, 0, 0, 0, 0, 0, 0, 0, 0,
1720  95, 96, 97, 98, 2, 0, 0, 0, 88, 0,
1721  13, 3, 0, 4, 14, 0, 89, 90, 0, 0,
1722  0, 5, 0, 0, 0, 6, 0, 0, 0, 0,
1723  0, 0, 7, 0, 0, 0, 8, 0, 0, 0,
1724  0, 9, 91, 0, 0, 0, 92, 93, 0, 10,
1725  0, 94, 11, 0, 0, 0, 0, 0, 3, 0,
1726  4, 95, 96, 97, 98, 0, 0, 0, 5, 0,
1727  12, 13, 6, 0, 279, 14, 280, 0, 0, 7,
1728  281, 0, 0, 8, 0, 0, 0, 3, 9, 4,
1729  0, 0, 0, 0, 0, 0, 10, 5, 0, 11,
1730  0, 6, 15, 0, 0, 0, 0, 0, 7, 16,
1731  0, 0, 8, 0, 0, 0, 0, 9, 13, 0,
1732  0, 0, 14, 0, 0, 10, 0, 0, 11, 0,
1733  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1734  0, 0, 0, 0, 0, 0, 0, 13, 0, 0,
1735  0, 14
1736 };
1737 
1738 static const yytype_int16 yycheck[] =
1739 {
1740  1, 37, 3, 4, 5, 6, 7, 8, 9, 10,
1741  11, 12, 13, 14, 27, 19, 68, 64, 194, 142,
1742  124, 76, 58, 145, 260, 38, 247, 105, 106, 133,
1743  7, 67, 9, 36, 83, 84, 99, 100, 101, 77,
1744  17, 78, 94, 80, 21, 108, 108, 85, 269, 85,
1745  271, 28, 102, 115, 111, 32, 100, 73, 74, 116,
1746  37, 115, 106, 112, 113, 26, 89, 90, 45, 111,
1747  169, 48, 73, 128, 196, 127, 312, 38, 39, 40,
1748  41, 42, 105, 119, 118, 119, 99, 210, 107, 50,
1749  67, 190, 111, 94, 71, 194, 99, 100, 101, 115,
1750  105, 117, 112, 111, 156, 105, 111, 68, 116, 70,
1751  107, 287, 99, 100, 101, 110, 292, 216, 112, 106,
1752  105, 157, 105, 124, 106, 105, 111, 105, 111, 105,
1753  107, 111, 133, 111, 105, 111, 106, 189, 151, 100,
1754  111, 142, 74, 242, 108, 197, 78, 199, 171, 172,
1755  173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1756  183, 184, 185, 186, 187, 188, 265, 214, 272, 273,
1757  110, 111, 38, 39, 40, 41, 42, 7, 108, 9,
1758  178, 179, 180, 181, 50, 174, 175, 17, 287, 125,
1759  109, 21, 111, 292, 127, 109, 209, 111, 28, 99,
1760  100, 101, 32, 207, 70, 241, 310, 37, 109, 210,
1761  111, 315, 316, 176, 177, 45, 268, 79, 48, 81,
1762  99, 100, 101, 108, 86, 87, 88, 89, 90, 91,
1763  92, 93, 126, 109, 100, 111, 75, 67, 122, 123,
1764  124, 71, 294, 295, 114, 109, 247, 111, 111, 109,
1765  254, 111, 114, 7, 290, 9, 100, 109, 259, 111,
1766  14, 108, 285, 17, 18, 19, 302, 21, 22, 111,
1767  283, 272, 273, 109, 28, 111, 108, 107, 32, 182,
1768  183, 35, 108, 37, 26, 108, 108, 72, 104, 104,
1769  109, 45, 109, 111, 48, 108, 38, 39, 40, 41,
1770  42, 113, 111, 109, 104, 16, 113, 109, 50, 310,
1771  105, 65, 66, 67, 315, 316, 12, 71, 72, 73,
1772  74, 23, 143, 278, 1, 85, 68, 67, 70, 247,
1773  71, 242, 185, 184, 188, -1, 186, -1, 187, -1,
1774  -1, -1, -1, -1, -1, 99, -1, -1, -1, 103,
1775  104, 105, 106, 107, 108, -1, -1, -1, 100, -1,
1776  -1, 7, -1, 9, 118, 119, 120, 121, 14, -1,
1777  -1, 17, 18, 19, -1, 21, 22, -1, -1, -1,
1778  -1, -1, 28, -1, -1, -1, 32, -1, -1, 35,
1779  -1, 37, 26, -1, -1, -1, -1, -1, -1, 45,
1780  -1, -1, 48, -1, 38, 39, 40, 41, 42, -1,
1781  -1, -1, -1, -1, -1, -1, 50, -1, -1, 65,
1782  66, 67, -1, -1, -1, 71, 72, 73, 74, -1,
1783  -1, -1, -1, -1, 68, -1, 70, -1, -1, -1,
1784  7, -1, 9, -1, -1, -1, -1, -1, -1, -1,
1785  17, 18, -1, 99, 21, -1, -1, 103, 104, 105,
1786  106, 28, 108, -1, -1, 32, 100, -1, -1, -1,
1787  37, -1, 118, 119, 120, 121, -1, -1, 45, -1,
1788  7, 48, 9, -1, -1, -1, -1, -1, -1, -1,
1789  17, 18, -1, -1, 21, -1, -1, -1, 65, -1,
1790  67, 28, -1, -1, 71, 32, 73, 74, -1, -1,
1791  37, -1, -1, -1, -1, -1, -1, -1, 45, -1,
1792  -1, 48, -1, -1, -1, -1, -1, -1, -1, -1,
1793  -1, -1, 99, -1, -1, -1, 103, 104, 65, 106,
1794  67, 108, -1, -1, 71, -1, 73, 74, -1, -1,
1795  -1, 118, 119, 120, 121, -1, -1, -1, -1, 7,
1796  -1, 9, -1, -1, -1, -1, -1, -1, -1, 17,
1797  18, -1, 99, 21, -1, -1, 103, 104, 105, -1,
1798  28, 108, -1, -1, 32, -1, -1, -1, -1, 37,
1799  -1, 118, 119, 120, 121, -1, -1, 45, -1, -1,
1800  48, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1801  -1, -1, -1, -1, -1, -1, -1, 65, -1, 67,
1802  7, -1, 9, 71, -1, 73, 74, -1, -1, -1,
1803  17, 18, -1, -1, 21, -1, -1, -1, -1, -1,
1804  -1, 28, -1, -1, -1, 32, -1, -1, -1, -1,
1805  37, 99, -1, -1, -1, 103, 104, -1, 45, 107,
1806  108, 48, -1, -1, -1, -1, -1, -1, -1, -1,
1807  118, 119, 120, 121, 0, -1, -1, -1, 65, -1,
1808  67, 7, -1, 9, 71, -1, 73, 74, -1, -1,
1809  -1, 17, -1, -1, -1, 21, -1, -1, -1, -1,
1810  -1, -1, 28, -1, -1, -1, 32, -1, -1, -1,
1811  -1, 37, 99, -1, -1, -1, 103, 104, -1, 45,
1812  -1, 108, 48, -1, -1, -1, -1, -1, 7, -1,
1813  9, 118, 119, 120, 121, -1, -1, -1, 17, -1,
1814  66, 67, 21, -1, 23, 71, 25, -1, -1, 28,
1815  29, -1, -1, 32, -1, -1, -1, 7, 37, 9,
1816  -1, -1, -1, -1, -1, -1, 45, 17, -1, 48,
1817  -1, 21, 98, -1, -1, -1, -1, -1, 28, 105,
1818  -1, -1, 32, -1, -1, -1, -1, 37, 67, -1,
1819  -1, -1, 71, -1, -1, 45, -1, -1, 48, -1,
1820  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1821  -1, -1, -1, -1, -1, -1, -1, 67, -1, -1,
1822  -1, 71
1823 };
1824 
1825  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1826  symbol of state STATE-NUM. */
1827 static const yytype_uint8 yystos[] =
1828 {
1829  0, 130, 0, 7, 9, 17, 21, 28, 32, 37,
1830  45, 48, 66, 67, 71, 98, 105, 131, 132, 133,
1831  134, 135, 139, 140, 154, 155, 158, 163, 163, 163,
1832  163, 163, 163, 163, 163, 163, 163, 133, 163, 163,
1833  163, 102, 99, 100, 101, 136, 159, 160, 161, 105,
1834  106, 141, 26, 38, 39, 40, 41, 42, 50, 68,
1835  70, 100, 152, 153, 136, 156, 157, 152, 115, 162,
1836  105, 111, 107, 142, 112, 100, 106, 136, 112, 99,
1837  101, 143, 160, 162, 105, 111, 156, 18, 65, 73,
1838  74, 99, 103, 104, 108, 118, 119, 120, 121, 163,
1839  167, 175, 176, 177, 178, 179, 180, 181, 182, 183,
1840  184, 185, 186, 187, 188, 189, 190, 191, 193, 110,
1841  144, 145, 146, 161, 14, 19, 22, 35, 72, 105,
1842  141, 154, 163, 168, 169, 170, 171, 173, 174, 193,
1843  50, 153, 137, 106, 153, 108, 105, 157, 105, 178,
1844  178, 163, 193, 152, 73, 74, 115, 117, 79, 81,
1845  86, 87, 88, 89, 90, 91, 92, 93, 114, 192,
1846  178, 122, 123, 124, 118, 119, 78, 80, 83, 84,
1847  112, 113, 77, 85, 125, 126, 127, 75, 76, 128,
1848  111, 116, 36, 136, 114, 169, 108, 108, 193, 108,
1849  152, 107, 169, 105, 100, 111, 107, 135, 138, 163,
1850  137, 111, 142, 147, 152, 109, 108, 193, 136, 191,
1851  178, 178, 178, 178, 180, 180, 181, 181, 182, 182,
1852  182, 182, 183, 183, 184, 185, 186, 187, 188, 193,
1853  191, 108, 106, 164, 165, 191, 72, 142, 193, 105,
1854  193, 104, 160, 50, 152, 107, 104, 148, 149, 150,
1855  109, 162, 165, 166, 116, 110, 136, 166, 108, 158,
1856  163, 174, 109, 109, 111, 105, 160, 113, 111, 23,
1857  25, 29, 151, 163, 144, 109, 109, 111, 191, 109,
1858  111, 107, 111, 193, 174, 174, 169, 172, 169, 104,
1859  105, 149, 152, 178, 165, 136, 107, 109, 193, 193,
1860  16, 113, 136, 109, 105, 109, 109, 169, 144, 169,
1861  169
1862 };
1863 
1864  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1865 static const yytype_uint8 yyr1[] =
1866 {
1867  0, 129, 130, 130, 130, 130, 130, 131, 132, 133,
1868  133, 134, 135, 136, 136, 136, 137, 137, 138, 138,
1869  139, 139, 140, 141, 141, 142, 143, 143, 144, 144,
1870  144, 145, 146, 146, 147, 147, 148, 148, 149, 150,
1871  150, 151, 151, 151, 152, 152, 152, 153, 153, 153,
1872  153, 153, 153, 153, 153, 154, 154, 154, 155, 155,
1873  156, 156, 157, 158, 159, 159, 160, 160, 161, 161,
1874  162, 162, 163, 163, 163, 163, 163, 163, 163, 163,
1875  163, 163, 163, 163, 164, 164, 164, 165, 166, 166,
1876  167, 167, 168, 168, 169, 169, 169, 169, 169, 169,
1877  170, 171, 172, 172, 173, 173, 173, 173, 174, 174,
1878  175, 175, 175, 175, 175, 176, 177, 177, 177, 177,
1879  177, 177, 178, 178, 178, 178, 178, 179, 179, 179,
1880  179, 180, 180, 180, 180, 181, 181, 181, 182, 182,
1881  182, 183, 183, 183, 183, 183, 184, 184, 184, 185,
1882  185, 186, 186, 187, 187, 188, 188, 189, 189, 190,
1883  190, 191, 191, 192, 192, 192, 192, 192, 192, 192,
1884  192, 192, 192, 192, 193, 193
1885 };
1886 
1887  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
1888 static const yytype_uint8 yyr2[] =
1889 {
1890  0, 2, 0, 2, 2, 2, 2, 2, 3, 1,
1891  1, 6, 5, 1, 1, 1, 0, 2, 4, 3,
1892  2, 2, 7, 2, 4, 0, 1, 1, 0, 1,
1893  1, 2, 5, 7, 1, 2, 1, 3, 5, 0,
1894  2, 1, 1, 1, 1, 6, 8, 1, 1, 1,
1895  1, 1, 1, 1, 2, 1, 1, 1, 5, 4,
1896  1, 3, 2, 4, 0, 1, 1, 3, 3, 5,
1897  0, 3, 0, 2, 2, 2, 2, 2, 2, 2,
1898  2, 2, 2, 2, 1, 3, 4, 1, 1, 3,
1899  1, 1, 1, 2, 1, 1, 1, 1, 1, 1,
1900  3, 5, 1, 3, 5, 7, 8, 8, 1, 2,
1901  1, 1, 1, 1, 3, 1, 1, 2, 2, 3,
1902  4, 5, 1, 2, 2, 2, 6, 1, 1, 1,
1903  1, 1, 3, 3, 3, 1, 3, 3, 1, 3,
1904  3, 1, 3, 3, 3, 3, 1, 3, 3, 1,
1905  3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
1906  5, 1, 3, 1, 1, 1, 1, 1, 1, 1,
1907  1, 1, 1, 1, 1, 3
1908 };
1909 
1910 
1911 #define yyerrok (yyerrstatus = 0)
1912 #define yyclearin (yychar = YYEMPTY)
1913 #define YYEMPTY (-2)
1914 #define YYEOF 0
1915 
1916 #define YYACCEPT goto yyacceptlab
1917 #define YYABORT goto yyabortlab
1918 #define YYERROR goto yyerrorlab
1919 
1920 
1921 #define YYRECOVERING() (!!yyerrstatus)
1922 
1923 #define YYBACKUP(Token, Value) \
1924 do \
1925  if (yychar == YYEMPTY) \
1926  { \
1927  yychar = (Token); \
1928  yylval = (Value); \
1929  YYPOPSTACK (yylen); \
1930  yystate = *yyssp; \
1931  goto yybackup; \
1932  } \
1933  else \
1934  { \
1935  yyerror (YY_("syntax error: cannot back up")); \
1936  YYERROR; \
1937  } \
1938 while (0)
1939 
1940 /* Error token number */
1941 #define YYTERROR 1
1942 #define YYERRCODE 256
1943 
1944 
1945 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1946  If N is 0, then set CURRENT to the empty location which ends
1947  the previous symbol: RHS[0] (always defined). */
1948 
1949 #ifndef YYLLOC_DEFAULT
1950 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1951  do \
1952  if (N) \
1953  { \
1954  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
1955  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
1956  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
1957  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1958  } \
1959  else \
1960  { \
1961  (Current).first_line = (Current).last_line = \
1962  YYRHSLOC (Rhs, 0).last_line; \
1963  (Current).first_column = (Current).last_column = \
1964  YYRHSLOC (Rhs, 0).last_column; \
1965  } \
1966  while (0)
1967 #endif
1968 
1969 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1970 
1971 
1972 /* Enable debugging if requested. */
1973 #if YYDEBUG
1974 
1975 # ifndef YYFPRINTF
1976 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1977 # define YYFPRINTF fprintf
1978 # endif
1979 
1980 # define YYDPRINTF(Args) \
1981 do { \
1982  if (yydebug) \
1983  YYFPRINTF Args; \
1984 } while (0)
1985 
1986 
1987 /* YY_LOCATION_PRINT -- Print the location on the stream.
1988  This macro was not mandated originally: define only if we know
1989  we won't break user code: when these are the locations we know. */
1990 
1991 #ifndef YY_LOCATION_PRINT
1992 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1993 
1994 /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
1995 
1996 __attribute__((__unused__))
1997 static unsigned
1998 yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
1999 {
2000  unsigned res = 0;
2001  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
2002  if (0 <= yylocp->first_line)
2003  {
2004  res += YYFPRINTF (yyo, "%d", yylocp->first_line);
2005  if (0 <= yylocp->first_column)
2006  res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
2007  }
2008  if (0 <= yylocp->last_line)
2009  {
2010  if (yylocp->first_line < yylocp->last_line)
2011  {
2012  res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
2013  if (0 <= end_col)
2014  res += YYFPRINTF (yyo, ".%d", end_col);
2015  }
2016  else if (0 <= end_col && yylocp->first_column < end_col)
2017  res += YYFPRINTF (yyo, "-%d", end_col);
2018  }
2019  return res;
2020  }
2021 
2022 # define YY_LOCATION_PRINT(File, Loc) \
2023  yy_location_print_ (File, &(Loc))
2024 
2025 # else
2026 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2027 # endif
2028 #endif
2029 
2030 
2031 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2032 do { \
2033  if (yydebug) \
2034  { \
2035  YYFPRINTF (stderr, "%s ", Title); \
2036  yy_symbol_print (stderr, \
2037  Type, Value, Location); \
2038  YYFPRINTF (stderr, "\n"); \
2039  } \
2040 } while (0)
2041 
2042 
2043 /*----------------------------------------.
2044 | Print this symbol's value on YYOUTPUT. |
2045 `----------------------------------------*/
2046 
2047 static void
2048 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
2049 {
2050  FILE *yyo = yyoutput;
2051  YYUSE (yyo);
2052  YYUSE (yylocationp);
2053  if (!yyvaluep)
2054  return;
2055 # ifdef YYPRINT
2056  if (yytype < YYNTOKENS)
2057  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2058 # endif
2059  YYUSE (yytype);
2060 }
2061 
2062 
2063 /*--------------------------------.
2064 | Print this symbol on YYOUTPUT. |
2065 `--------------------------------*/
2066 
2067 static void
2068 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
2069 {
2070  YYFPRINTF (yyoutput, "%s %s (",
2071  yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
2072 
2073  YY_LOCATION_PRINT (yyoutput, *yylocationp);
2074  YYFPRINTF (yyoutput, ": ");
2075  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
2076  YYFPRINTF (yyoutput, ")");
2077 }
2078 
2079 /*------------------------------------------------------------------.
2080 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
2081 | TOP (included). |
2082 `------------------------------------------------------------------*/
2083 
2084 static void
2085 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
2086 {
2087  YYFPRINTF (stderr, "Stack now");
2088  for (; yybottom <= yytop; yybottom++)
2089  {
2090  int yybot = *yybottom;
2091  YYFPRINTF (stderr, " %d", yybot);
2092  }
2093  YYFPRINTF (stderr, "\n");
2094 }
2095 
2096 # define YY_STACK_PRINT(Bottom, Top) \
2097 do { \
2098  if (yydebug) \
2099  yy_stack_print ((Bottom), (Top)); \
2100 } while (0)
2101 
2102 
2103 /*------------------------------------------------.
2104 | Report that the YYRULE is going to be reduced. |
2105 `------------------------------------------------*/
2106 
2107 static void
2108 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
2109 {
2110  unsigned long int yylno = yyrline[yyrule];
2111  int yynrhs = yyr2[yyrule];
2112  int yyi;
2113  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2114  yyrule - 1, yylno);
2115  /* The symbols being reduced. */
2116  for (yyi = 0; yyi < yynrhs; yyi++)
2117  {
2118  YYFPRINTF (stderr, " $%d = ", yyi + 1);
2119  yy_symbol_print (stderr,
2120  yystos[yyssp[yyi + 1 - yynrhs]],
2121  &(yyvsp[(yyi + 1) - (yynrhs)])
2122  , &(yylsp[(yyi + 1) - (yynrhs)]) );
2123  YYFPRINTF (stderr, "\n");
2124  }
2125 }
2126 
2127 # define YY_REDUCE_PRINT(Rule) \
2128 do { \
2129  if (yydebug) \
2130  yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
2131 } while (0)
2132 
2133 /* Nonzero means print parse trace. It is left uninitialized so that
2134  multiple parsers can coexist. */
2135 int yydebug;
2136 #else /* !YYDEBUG */
2137 # define YYDPRINTF(Args)
2138 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2139 # define YY_STACK_PRINT(Bottom, Top)
2140 # define YY_REDUCE_PRINT(Rule)
2141 #endif /* !YYDEBUG */
2142 
2143 
2144 /* YYINITDEPTH -- initial size of the parser's stacks. */
2145 #ifndef YYINITDEPTH
2146 # define YYINITDEPTH 200
2147 #endif
2148 
2149 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2150  if the built-in stack extension method is used).
2151 
2152  Do not make this value too large; the results are undefined if
2153  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2154  evaluated with infinite-precision integer arithmetic. */
2155 
2156 #ifndef YYMAXDEPTH
2157 # define YYMAXDEPTH 10000
2158 #endif
2159 
2160 
2161 #if YYERROR_VERBOSE
2162 
2163 # ifndef yystrlen
2164 # if defined __GLIBC__ && defined _STRING_H
2165 # define yystrlen strlen
2166 # else
2167 /* Return the length of YYSTR. */
2168 static YYSIZE_T
2169 yystrlen (const char *yystr)
2170 {
2171  YYSIZE_T yylen;
2172  for (yylen = 0; yystr[yylen]; yylen++)
2173  continue;
2174  return yylen;
2175 }
2176 # endif
2177 # endif
2178 
2179 # ifndef yystpcpy
2180 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2181 # define yystpcpy stpcpy
2182 # else
2183 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2184  YYDEST. */
2185 static char *
2186 yystpcpy (char *yydest, const char *yysrc)
2187 {
2188  char *yyd = yydest;
2189  const char *yys = yysrc;
2190 
2191  while ((*yyd++ = *yys++) != '\0')
2192  continue;
2193 
2194  return yyd - 1;
2195 }
2196 # endif
2197 # endif
2198 
2199 # ifndef yytnamerr
2200 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2201  quotes and backslashes, so that it's suitable for yyerror. The
2202  heuristic is that double-quoting is unnecessary unless the string
2203  contains an apostrophe, a comma, or backslash (other than
2204  backslash-backslash). YYSTR is taken from yytname. If YYRES is
2205  null, do not copy; instead, return the length of what the result
2206  would have been. */
2207 static YYSIZE_T
2208 yytnamerr (char *yyres, const char *yystr)
2209 {
2210  if (*yystr == '"')
2211  {
2212  YYSIZE_T yyn = 0;
2213  char const *yyp = yystr;
2214 
2215  for (;;)
2216  switch (*++yyp)
2217  {
2218  case '\'':
2219  case ',':
2220  goto do_not_strip_quotes;
2221 
2222  case '\\':
2223  if (*++yyp != '\\')
2224  goto do_not_strip_quotes;
2225  /* Fall through. */
2226  default:
2227  if (yyres)
2228  yyres[yyn] = *yyp;
2229  yyn++;
2230  break;
2231 
2232  case '"':
2233  if (yyres)
2234  yyres[yyn] = '\0';
2235  return yyn;
2236  }
2237  do_not_strip_quotes: ;
2238  }
2239 
2240  if (! yyres)
2241  return yystrlen (yystr);
2242 
2243  return yystpcpy (yyres, yystr) - yyres;
2244 }
2245 # endif
2246 
2247 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
2248  about the unexpected token YYTOKEN for the state stack whose top is
2249  YYSSP.
2250 
2251  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
2252  not large enough to hold the message. In that case, also set
2253  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
2254  required number of bytes is too large to store. */
2255 static int
2256 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
2257  yytype_int16 *yyssp, int yytoken)
2258 {
2259  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
2260  YYSIZE_T yysize = yysize0;
2261  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2262  /* Internationalized format string. */
2263  const char *yyformat = YY_NULL;
2264  /* Arguments of yyformat. */
2265  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2266  /* Number of reported tokens (one for the "unexpected", one per
2267  "expected"). */
2268  int yycount = 0;
2269 
2270  /* There are many possibilities here to consider:
2271  - If this state is a consistent state with a default action, then
2272  the only way this function was invoked is if the default action
2273  is an error action. In that case, don't check for expected
2274  tokens because there are none.
2275  - The only way there can be no lookahead present (in yychar) is if
2276  this state is a consistent state with a default action. Thus,
2277  detecting the absence of a lookahead is sufficient to determine
2278  that there is no unexpected or expected token to report. In that
2279  case, just report a simple "syntax error".
2280  - Don't assume there isn't a lookahead just because this state is a
2281  consistent state with a default action. There might have been a
2282  previous inconsistent state, consistent state with a non-default
2283  action, or user semantic action that manipulated yychar.
2284  - Of course, the expected token list depends on states to have
2285  correct lookahead information, and it depends on the parser not
2286  to perform extra reductions after fetching a lookahead from the
2287  scanner and before detecting a syntax error. Thus, state merging
2288  (from LALR or IELR) and default reductions corrupt the expected
2289  token list. However, the list is correct for canonical LR with
2290  one exception: it will still contain any token that will not be
2291  accepted due to an error action in a later state.
2292  */
2293  if (yytoken != YYEMPTY)
2294  {
2295  int yyn = yypact[*yyssp];
2296  yyarg[yycount++] = yytname[yytoken];
2297  if (!yypact_value_is_default (yyn))
2298  {
2299  /* Start YYX at -YYN if negative to avoid negative indexes in
2300  YYCHECK. In other words, skip the first -YYN actions for
2301  this state because they are default actions. */
2302  int yyxbegin = yyn < 0 ? -yyn : 0;
2303  /* Stay within bounds of both yycheck and yytname. */
2304  int yychecklim = YYLAST - yyn + 1;
2305  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2306  int yyx;
2307 
2308  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2309  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
2310  && !yytable_value_is_error (yytable[yyx + yyn]))
2311  {
2312  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2313  {
2314  yycount = 1;
2315  yysize = yysize0;
2316  break;
2317  }
2318  yyarg[yycount++] = yytname[yyx];
2319  {
2320  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
2321  if (! (yysize <= yysize1
2322  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
2323  return 2;
2324  yysize = yysize1;
2325  }
2326  }
2327  }
2328  }
2329 
2330  switch (yycount)
2331  {
2332 # define YYCASE_(N, S) \
2333  case N: \
2334  yyformat = S; \
2335  break
2336  YYCASE_(0, YY_("syntax error"));
2337  YYCASE_(1, YY_("syntax error, unexpected %s"));
2338  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
2339  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
2340  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
2341  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
2342 # undef YYCASE_
2343  }
2344 
2345  {
2346  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
2347  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
2348  return 2;
2349  yysize = yysize1;
2350  }
2351 
2352  if (*yymsg_alloc < yysize)
2353  {
2354  *yymsg_alloc = 2 * yysize;
2355  if (! (yysize <= *yymsg_alloc
2356  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
2357  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
2358  return 1;
2359  }
2360 
2361  /* Avoid sprintf, as that infringes on the user's name space.
2362  Don't have undefined behavior even if the translation
2363  produced a string with the wrong number of "%s"s. */
2364  {
2365  char *yyp = *yymsg;
2366  int yyi = 0;
2367  while ((*yyp = *yyformat) != '\0')
2368  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
2369  {
2370  yyp += yytnamerr (yyp, yyarg[yyi++]);
2371  yyformat += 2;
2372  }
2373  else
2374  {
2375  yyp++;
2376  yyformat++;
2377  }
2378  }
2379  return 0;
2380 }
2381 #endif /* YYERROR_VERBOSE */
2382 
2383 /*-----------------------------------------------.
2384 | Release the memory associated to this symbol. |
2385 `-----------------------------------------------*/
2386 
2387 static void
2388 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
2389 {
2390  YYUSE (yyvaluep);
2391  YYUSE (yylocationp);
2392  if (!yymsg)
2393  yymsg = "Deleting";
2394  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2395 
2397  YYUSE (yytype);
2399 }
2400 
2401 
2402 
2403 
2404 /* The lookahead symbol. */
2406 
2407 /* The semantic value of the lookahead symbol. */
2409 /* Location data for the lookahead symbol. */
2411 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2412  = { 1, 1, 1, 1 }
2413 # endif
2414 ;
2415 /* Number of syntax errors so far. */
2417 
2418 
2419 /*----------.
2420 | yyparse. |
2421 `----------*/
2422 
2423 int
2424 yyparse (void)
2425 {
2426  int yystate;
2427  /* Number of tokens to shift before error messages enabled. */
2428  int yyerrstatus;
2429 
2430  /* The stacks and their tools:
2431  'yyss': related to states.
2432  'yyvs': related to semantic values.
2433  'yyls': related to locations.
2434 
2435  Refer to the stacks through separate pointers, to allow yyoverflow
2436  to reallocate them elsewhere. */
2437 
2438  /* The state stack. */
2439  yytype_int16 yyssa[YYINITDEPTH];
2440  yytype_int16 *yyss;
2441  yytype_int16 *yyssp;
2442 
2443  /* The semantic value stack. */
2444  YYSTYPE yyvsa[YYINITDEPTH];
2445  YYSTYPE *yyvs;
2446  YYSTYPE *yyvsp;
2447 
2448  /* The location stack. */
2449  YYLTYPE yylsa[YYINITDEPTH];
2450  YYLTYPE *yyls;
2451  YYLTYPE *yylsp;
2452 
2453  /* The locations where the error started and ended. */
2454  YYLTYPE yyerror_range[3];
2455 
2456  YYSIZE_T yystacksize;
2457 
2458  int yyn;
2459  int yyresult;
2460  /* Lookahead token as an internal (translated) token number. */
2461  int yytoken = 0;
2462  /* The variables used to return semantic value and location from the
2463  action routines. */
2464  YYSTYPE yyval;
2465  YYLTYPE yyloc;
2466 
2467 #if YYERROR_VERBOSE
2468  /* Buffer for error messages, and its allocated size. */
2469  char yymsgbuf[128];
2470  char *yymsg = yymsgbuf;
2471  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
2472 #endif
2473 
2474 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
2475 
2476  /* The number of symbols on the RHS of the reduced rule.
2477  Keep to zero when no symbol should be popped. */
2478  int yylen = 0;
2479 
2480  yyssp = yyss = yyssa;
2481  yyvsp = yyvs = yyvsa;
2482  yylsp = yyls = yylsa;
2483  yystacksize = YYINITDEPTH;
2484 
2485  YYDPRINTF ((stderr, "Starting parse\n"));
2486 
2487  yystate = 0;
2488  yyerrstatus = 0;
2489  yynerrs = 0;
2490  yychar = YYEMPTY; /* Cause a token to be read. */
2491  yylsp[0] = yylloc;
2492  goto yysetstate;
2493 
2494 /*------------------------------------------------------------.
2495 | yynewstate -- Push a new state, which is found in yystate. |
2496 `------------------------------------------------------------*/
2497  yynewstate:
2498  /* In all cases, when you get here, the value and location stacks
2499  have just been pushed. So pushing a state here evens the stacks. */
2500  yyssp++;
2501 
2502  yysetstate:
2503  *yyssp = yystate;
2504 
2505  if (yyss + yystacksize - 1 <= yyssp)
2506  {
2507  /* Get the current used size of the three stacks, in elements. */
2508  YYSIZE_T yysize = yyssp - yyss + 1;
2509 
2510 #ifdef yyoverflow
2511  {
2512  /* Give user a chance to reallocate the stack. Use copies of
2513  these so that the &'s don't force the real ones into
2514  memory. */
2515  YYSTYPE *yyvs1 = yyvs;
2516  yytype_int16 *yyss1 = yyss;
2517  YYLTYPE *yyls1 = yyls;
2518 
2519  /* Each stack pointer address is followed by the size of the
2520  data in use in that stack, in bytes. This used to be a
2521  conditional around just the two extra args, but that might
2522  be undefined if yyoverflow is a macro. */
2523  yyoverflow (YY_("memory exhausted"),
2524  &yyss1, yysize * sizeof (*yyssp),
2525  &yyvs1, yysize * sizeof (*yyvsp),
2526  &yyls1, yysize * sizeof (*yylsp),
2527  &yystacksize);
2528 
2529  yyls = yyls1;
2530  yyss = yyss1;
2531  yyvs = yyvs1;
2532  }
2533 #else /* no yyoverflow */
2534 # ifndef YYSTACK_RELOCATE
2535  goto yyexhaustedlab;
2536 # else
2537  /* Extend the stack our own way. */
2538  if (YYMAXDEPTH <= yystacksize)
2539  goto yyexhaustedlab;
2540  yystacksize *= 2;
2541  if (YYMAXDEPTH < yystacksize)
2542  yystacksize = YYMAXDEPTH;
2543 
2544  {
2545  yytype_int16 *yyss1 = yyss;
2546  union yyalloc *yyptr =
2547  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2548  if (! yyptr)
2549  goto yyexhaustedlab;
2550  YYSTACK_RELOCATE (yyss_alloc, yyss);
2551  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
2552  YYSTACK_RELOCATE (yyls_alloc, yyls);
2553 # undef YYSTACK_RELOCATE
2554  if (yyss1 != yyssa)
2555  YYSTACK_FREE (yyss1);
2556  }
2557 # endif
2558 #endif /* no yyoverflow */
2559 
2560  yyssp = yyss + yysize - 1;
2561  yyvsp = yyvs + yysize - 1;
2562  yylsp = yyls + yysize - 1;
2563 
2564  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2565  (unsigned long int) yystacksize));
2566 
2567  if (yyss + yystacksize - 1 <= yyssp)
2568  YYABORT;
2569  }
2570 
2571  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2572 
2573  if (yystate == YYFINAL)
2574  YYACCEPT;
2575 
2576  goto yybackup;
2577 
2578 /*-----------.
2579 | yybackup. |
2580 `-----------*/
2581 yybackup:
2582 
2583  /* Do appropriate processing given the current state. Read a
2584  lookahead token if we need one and don't already have one. */
2585 
2586  /* First try to decide what to do without reference to lookahead token. */
2587  yyn = yypact[yystate];
2588  if (yypact_value_is_default (yyn))
2589  goto yydefault;
2590 
2591  /* Not known => get a lookahead token if don't already have one. */
2592 
2593  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
2594  if (yychar == YYEMPTY)
2595  {
2596  YYDPRINTF ((stderr, "Reading a token: "));
2597  yychar = yylex ();
2598  }
2599 
2600  if (yychar <= YYEOF)
2601  {
2602  yychar = yytoken = YYEOF;
2603  YYDPRINTF ((stderr, "Now at end of input.\n"));
2604  }
2605  else
2606  {
2607  yytoken = YYTRANSLATE (yychar);
2608  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2609  }
2610 
2611  /* If the proper action on seeing token YYTOKEN is to reduce or to
2612  detect an error, take that action. */
2613  yyn += yytoken;
2614  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2615  goto yydefault;
2616  yyn = yytable[yyn];
2617  if (yyn <= 0)
2618  {
2619  if (yytable_value_is_error (yyn))
2620  goto yyerrlab;
2621  yyn = -yyn;
2622  goto yyreduce;
2623  }
2624 
2625  /* Count tokens shifted since error; after three, turn off error
2626  status. */
2627  if (yyerrstatus)
2628  yyerrstatus--;
2629 
2630  /* Shift the lookahead token. */
2631  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2632 
2633  /* Discard the shifted token. */
2634  yychar = YYEMPTY;
2635 
2636  yystate = yyn;
2638  *++yyvsp = yylval;
2640  *++yylsp = yylloc;
2641  goto yynewstate;
2642 
2643 
2644 /*-----------------------------------------------------------.
2645 | yydefault -- do the default action for the current state. |
2646 `-----------------------------------------------------------*/
2647 yydefault:
2648  yyn = yydefact[yystate];
2649  if (yyn == 0)
2650  goto yyerrlab;
2651  goto yyreduce;
2652 
2653 
2654 /*-----------------------------.
2655 | yyreduce -- Do a reduction. |
2656 `-----------------------------*/
2657 yyreduce:
2658  /* yyn is the number of a rule to reduce with. */
2659  yylen = yyr2[yyn];
2660 
2661  /* If YYLEN is nonzero, implement the default value of the action:
2662  '$$ = $1'.
2663 
2664  Otherwise, the following line sets YYVAL to garbage.
2665  This behavior is undocumented and Bison
2666  users should not rely upon it. Assigning to YYVAL
2667  unconditionally makes the parser a bit smaller, and it avoids a
2668  GCC warning that YYVAL may be used uninitialized. */
2669  yyval = yyvsp[1-yylen];
2670 
2671  /* Default location. */
2672  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
2673  YY_REDUCE_PRINT (yyn);
2674  switch (yyn)
2675  {
2676  case 2:
2677 #line 1095 "hlsl.y" /* yacc.c:1646 */
2678  {
2679  }
2680 #line 2681 "hlsl.tab.c" /* yacc.c:1646 */
2681  break;
2682 
2683  case 3:
2684 #line 1098 "hlsl.y" /* yacc.c:1646 */
2685  {
2686  const struct hlsl_ir_function_decl *decl;
2687 
2688  decl = get_overloaded_func(&hlsl_ctx.functions, (yyvsp[0].function).name, (yyvsp[0].function).decl->parameters, TRUE);
2689  if (decl && !decl->func->intrinsic)
2690  {
2691  if (decl->body && (yyvsp[0].function).decl->body)
2692  {
2693  hlsl_report_message((yyvsp[0].function).decl->node.loc.file, (yyvsp[0].function).decl->node.loc.line,
2694  (yyvsp[0].function).decl->node.loc.col, HLSL_LEVEL_ERROR,
2695  "redefinition of function %s", debugstr_a((yyvsp[0].function).name));
2696  return 1;
2697  }
2698  else if (!compare_hlsl_types(decl->node.data_type, (yyvsp[0].function).decl->node.data_type))
2699  {
2700  hlsl_report_message((yyvsp[0].function).decl->node.loc.file, (yyvsp[0].function).decl->node.loc.line,
2701  (yyvsp[0].function).decl->node.loc.col, HLSL_LEVEL_ERROR,
2702  "redefining function %s with a different return type",
2703  debugstr_a((yyvsp[0].function).name));
2704  hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_NOTE,
2705  "%s previously declared here",
2706  debugstr_a((yyvsp[0].function).name));
2707  return 1;
2708  }
2709  }
2710 
2711  if ((yyvsp[0].function).decl->node.data_type->base_type == HLSL_TYPE_VOID && (yyvsp[0].function).decl->semantic)
2712  {
2713  hlsl_report_message((yyvsp[0].function).decl->node.loc.file, (yyvsp[0].function).decl->node.loc.line,
2714  (yyvsp[0].function).decl->node.loc.col, HLSL_LEVEL_ERROR,
2715  "void function with a semantic");
2716  }
2717 
2718  TRACE("Adding function '%s' to the function list.\n", (yyvsp[0].function).name);
2719  add_function_decl(&hlsl_ctx.functions, (yyvsp[0].function).name, (yyvsp[0].function).decl, FALSE);
2720  }
2721 #line 2722 "hlsl.tab.c" /* yacc.c:1646 */
2722  break;
2723 
2724  case 4:
2725 #line 1135 "hlsl.y" /* yacc.c:1646 */
2726  {
2727  TRACE("Declaration statement parsed.\n");
2728  }
2729 #line 2730 "hlsl.tab.c" /* yacc.c:1646 */
2730  break;
2731 
2732  case 5:
2733 #line 1139 "hlsl.y" /* yacc.c:1646 */
2734  {
2735  }
2736 #line 2737 "hlsl.tab.c" /* yacc.c:1646 */
2737  break;
2738 
2739  case 6:
2740 #line 1142 "hlsl.y" /* yacc.c:1646 */
2741  {
2742  TRACE("Skipping stray semicolon.\n");
2743  }
2744 #line 2745 "hlsl.tab.c" /* yacc.c:1646 */
2745  break;
2746 
2747  case 7:
2748 #line 1147 "hlsl.y" /* yacc.c:1646 */
2749  {
2750  const char **new_array = NULL;
2751 
2752  TRACE("Updating line information to file %s, line %u\n", debugstr_a((yyvsp[0].name)), (yyvsp[-1].intval));
2753  hlsl_ctx.line_no = (yyvsp[-1].intval);
2754  if (strcmp((yyvsp[0].name), hlsl_ctx.source_file))
2755  new_array = d3dcompiler_realloc(hlsl_ctx.source_files,
2756  sizeof(*hlsl_ctx.source_files) * (hlsl_ctx.source_files_count + 1));
2757 
2758  if (new_array)
2759  {
2760  hlsl_ctx.source_files = new_array;
2761  hlsl_ctx.source_files[hlsl_ctx.source_files_count++] = (yyvsp[0].name);
2762  hlsl_ctx.source_file = (yyvsp[0].name);
2763  }
2764  else
2765  {
2766  d3dcompiler_free((yyvsp[0].name));
2767  }
2768  }
2769 #line 2770 "hlsl.tab.c" /* yacc.c:1646 */
2770  break;
2771 
2772  case 8:
2773 #line 1169 "hlsl.y" /* yacc.c:1646 */
2774  {
2775  struct source_location loc;
2776 
2777  set_location(&loc, &(yylsp[0]));
2778  if (!(yyvsp[-1].list))
2779  {
2780  if (!(yyvsp[-2].type)->name)
2781  {
2782  hlsl_report_message(loc.file, loc.line, loc.col,
2783  HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables");
2784  }
2785  check_type_modifiers((yyvsp[-2].type)->modifiers, &loc);
2786  }
2787  (yyval.list) = declare_vars((yyvsp[-2].type), 0, (yyvsp[-1].list));
2788  }
2789 #line 2790 "hlsl.tab.c" /* yacc.c:1646 */
2790  break;
2791 
2792  case 11:
2793 #line 1189 "hlsl.y" /* yacc.c:1646 */
2794  {
2795  BOOL ret;
2796  struct source_location loc;
2797 
2798  TRACE("Structure %s declaration.\n", debugstr_a((yyvsp[-3].name)));
2799  set_location(&loc, &(yylsp[-5]));
2800  check_invalid_matrix_modifiers((yyvsp[-5].modifiers), &loc);
2801  (yyval.type) = new_struct_type((yyvsp[-3].name), (yyvsp[-5].modifiers), (yyvsp[-1].list));
2802 
2803  if (get_variable(hlsl_ctx.cur_scope, (yyvsp[-3].name)))
2804  {
2805  hlsl_report_message(hlsl_ctx.source_file, (yylsp[-3]).first_line, (yylsp[-3]).first_column,
2806  HLSL_LEVEL_ERROR, "redefinition of '%s'", (yyvsp[-3].name));
2807  return 1;
2808  }
2809 
2810  ret = add_type_to_scope(hlsl_ctx.cur_scope, (yyval.type));
2811  if (!ret)
2812  {
2813  hlsl_report_message(hlsl_ctx.source_file, (yylsp[-3]).first_line, (yylsp[-3]).first_column,
2814  HLSL_LEVEL_ERROR, "redefinition of struct '%s'", (yyvsp[-3].name));
2815  return 1;
2816  }
2817  }
2818 #line 2819 "hlsl.tab.c" /* yacc.c:1646 */
2819  break;
2820 
2821  case 12:
2822 #line 1215 "hlsl.y" /* yacc.c:1646 */
2823  {
2824  struct source_location loc;
2825 
2826  TRACE("Anonymous structure declaration.\n");
2827  set_location(&loc, &(yylsp[-4]));
2828  check_invalid_matrix_modifiers((yyvsp[-4].modifiers), &loc);
2829  (yyval.type) = new_struct_type(NULL, (yyvsp[-4].modifiers), (yyvsp[-1].list));
2830  }
2831 #line 2832 "hlsl.tab.c" /* yacc.c:1646 */
2832  break;
2833 
2834  case 16:
2835 #line 1229 "hlsl.y" /* yacc.c:1646 */
2836  {
2837  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
2838  list_init((yyval.list));
2839  }
2840 #line 2841 "hlsl.tab.c" /* yacc.c:1646 */
2841  break;
2842 
2843  case 17:
2844 #line 1234 "hlsl.y" /* yacc.c:1646 */
2845  {
2846  BOOL ret;
2847  struct hlsl_struct_field *field, *next;
2848 
2849  (yyval.list) = (yyvsp[-1].list);
2851  {
2852  ret = add_struct_field((yyval.list), field);
2853  if (ret == FALSE)
2854  {
2855  hlsl_report_message(hlsl_ctx.source_file, (yylsp[0]).first_line, (yylsp[0]).first_column,
2856  HLSL_LEVEL_ERROR, "redefinition of '%s'", field->name);
2858  }
2859  }
2860  d3dcompiler_free((yyvsp[0].list));
2861  }
2862 #line 2863 "hlsl.tab.c" /* yacc.c:1646 */
2863  break;
2864 
2865  case 18:
2866 #line 1253 "hlsl.y" /* yacc.c:1646 */
2867  {
2868  (yyval.list) = gen_struct_fields((yyvsp[-2].type), (yyvsp[-3].modifiers), (yyvsp[-1].list));
2869  }
2870 #line 2871 "hlsl.tab.c" /* yacc.c:1646 */
2871  break;
2872 
2873  case 19:
2874 #line 1257 "hlsl.y" /* yacc.c:1646 */
2875  {
2876  (yyval.list) = gen_struct_fields((yyvsp[-2].type), 0, (yyvsp[-1].list));
2877  }
2878 #line 2879 "hlsl.tab.c" /* yacc.c:1646 */
2879  break;
2880 
2881  case 20:
2882 #line 1262 "hlsl.y" /* yacc.c:1646 */
2883  {
2884  TRACE("Function %s parsed.\n", (yyvsp[-1].function).name);
2885  (yyval.function) = (yyvsp[-1].function);
2886  (yyval.function).decl->body = (yyvsp[0].list);
2887  pop_scope(&hlsl_ctx);
2888  }
2889 #line 2890 "hlsl.tab.c" /* yacc.c:1646 */
2890  break;
2891 
2892  case 21:
2893 #line 1269 "hlsl.y" /* yacc.c:1646 */
2894  {
2895  TRACE("Function prototype for %s.\n", (yyvsp[-1].function).name);
2896  (yyval.function) = (yyvsp[-1].function);
2897  pop_scope(&hlsl_ctx);
2898  }
2899 #line 2900 "hlsl.tab.c" /* yacc.c:1646 */
2900  break;
2901 
2902  case 22:
2903 #line 1276 "hlsl.y" /* yacc.c:1646 */
2904  {
2905  if (get_variable(hlsl_ctx.globals, (yyvsp[-4].name)))
2906  {
2907  hlsl_report_message(hlsl_ctx.source_file, (yylsp[-4]).first_line, (yylsp[-4]).first_column,
2908  HLSL_LEVEL_ERROR, "redefinition of '%s'\n", (yyvsp[-4].name));
2909  return 1;
2910  }
2911  if ((yyvsp[-5].type)->base_type == HLSL_TYPE_VOID && (yyvsp[0].colon_attribute).semantic)
2912  {
2913  hlsl_report_message(hlsl_ctx.source_file, (yylsp[0]).first_line, (yylsp[0]).first_column,
2914  HLSL_LEVEL_ERROR, "void function with a semantic");
2915  }
2916 
2917  if ((yyvsp[0].colon_attribute).reg_reservation)
2918  {
2919  FIXME("Unexpected register reservation for a function.\n");
2920  d3dcompiler_free((yyvsp[0].colon_attribute).reg_reservation);
2921  }
2922  (yyval.function).decl = new_func_decl((yyvsp[-5].type), (yyvsp[-2].list));
2923  if (!(yyval.function).decl)
2924  {
2925  ERR("Out of memory.\n");
2926  return -1;
2927  }
2928  (yyval.function).name = (yyvsp[-4].name);
2929  (yyval.function).decl->semantic = (yyvsp[0].colon_attribute).semantic;
2930  set_location(&(yyval.function).decl->node.loc, &(yylsp[-4]));
2931  }
2932 #line 2933 "hlsl.tab.c" /* yacc.c:1646 */
2933  break;
2934 
2935  case 23:
2936 #line 1306 "hlsl.y" /* yacc.c:1646 */
2937  {
2938  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
2939  list_init((yyval.list));
2940  }
2941 #line 2942 "hlsl.tab.c" /* yacc.c:1646 */
2942  break;
2943 
2944  case 24:
2945 #line 1311 "hlsl.y" /* yacc.c:1646 */
2946  {
2947  pop_scope(&hlsl_ctx);
2948  (yyval.list) = (yyvsp[-1].list);
2949  }
2950 #line 2951 "hlsl.tab.c" /* yacc.c:1646 */
2951  break;
2952 
2953  case 25:
2954 #line 1317 "hlsl.y" /* yacc.c:1646 */
2955  {
2956  push_scope(&hlsl_ctx);
2957  }
2958 #line 2959 "hlsl.tab.c" /* yacc.c:1646 */
2959  break;
2960 
2961  case 28:
2962 #line 1325 "hlsl.y" /* yacc.c:1646 */
2963  {
2964  (yyval.colon_attribute).semantic = NULL;
2966  }
2967 #line 2968 "hlsl.tab.c" /* yacc.c:1646 */
2968  break;
2969 
2970  case 29:
2971 #line 1330 "hlsl.y" /* yacc.c:1646 */
2972  {
2973  (yyval.colon_attribute).semantic = (yyvsp[0].name);
2975  }
2976 #line 2977 "hlsl.tab.c" /* yacc.c:1646 */
2977  break;
2978 
2979  case 30:
2980 #line 1335 "hlsl.y" /* yacc.c:1646 */
2981  {
2982  (yyval.colon_attribute).semantic = NULL;
2983  (yyval.colon_attribute).reg_reservation = (yyvsp[0].reg_reservation);
2984  }
2985 #line 2986 "hlsl.tab.c" /* yacc.c:1646 */
2986  break;
2987 
2988  case 31:
2989 #line 1341 "hlsl.y" /* yacc.c:1646 */
2990  {
2991  (yyval.name) = (yyvsp[0].name);
2992  }
2993 #line 2994 "hlsl.tab.c" /* yacc.c:1646 */
2994  break;
2995 
2996  case 32:
2997 #line 1347 "hlsl.y" /* yacc.c:1646 */
2998  {
2999  (yyval.reg_reservation) = parse_reg_reservation((yyvsp[-1].name));
3000  d3dcompiler_free((yyvsp[-1].name));
3001  }
3002 #line 3003 "hlsl.tab.c" /* yacc.c:1646 */
3003  break;
3004 
3005  case 33:
3006 #line 1352 "hlsl.y" /* yacc.c:1646 */
3007  {
3008  FIXME("Ignoring shader target %s in a register reservation.\n", debugstr_a((yyvsp[-3].name)));
3009  d3dcompiler_free((yyvsp[-3].name));
3010 
3011  (yyval.reg_reservation) = parse_reg_reservation((yyvsp[-1].name));
3012  d3dcompiler_free((yyvsp[-1].name));
3013  }
3014 #line 3015 "hlsl.tab.c" /* yacc.c:1646 */
3015  break;
3016 
3017  case 34:
3018 #line 1361 "hlsl.y" /* yacc.c:1646 */
3019  {
3020  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3021  list_init((yyval.list));
3022  }
3023 #line 3024 "hlsl.tab.c" /* yacc.c:1646 */
3024  break;
3025 
3026  case 35:
3027 #line 1366 "hlsl.y" /* yacc.c:1646 */
3028  {
3029  (yyval.list) = (yyvsp[0].list);
3030  }
3031 #line 3032 "hlsl.tab.c" /* yacc.c:1646 */
3032  break;
3033 
3034  case 36:
3035 #line 1371 "hlsl.y" /* yacc.c:1646 */
3036  {
3037  struct source_location loc;
3038 
3039  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3040  list_init((yyval.list));
3041  set_location(&loc, &(yylsp[0]));
3042  if (!add_func_parameter((yyval.list), &(yyvsp[0].parameter), &loc))
3043  {
3044  ERR("Error adding function parameter %s.\n", (yyvsp[0].parameter).name);
3046  return -1;
3047  }
3048  }
3049 #line 3050 "hlsl.tab.c" /* yacc.c:1646 */
3050  break;
3051 
3052  case 37:
3053 #line 1385 "hlsl.y" /* yacc.c:1646 */
3054  {
3055  struct source_location loc;
3056 
3057  (yyval.list) = (yyvsp[-2].list);
3058  set_location(&loc, &(yylsp[0]));
3059  if (!add_func_parameter((yyval.list), &(yyvsp[0].parameter), &loc))
3060  {
3062  "duplicate parameter %s", (yyvsp[0].parameter).name);
3063  return 1;
3064  }
3065  }
3066 #line 3067 "hlsl.tab.c" /* yacc.c:1646 */
3067  break;
3068 
3069  case 38:
3070 #line 1399 "hlsl.y" /* yacc.c:1646 */
3071  {
3072  (yyval.parameter).modifiers = (yyvsp[-4].modifiers) ? (yyvsp[-4].modifiers) : HLSL_MODIFIER_IN;
3073  (yyval.parameter).modifiers |= (yyvsp[-3].modifiers);
3074  (yyval.parameter).type = (yyvsp[-2].type);
3075  (yyval.parameter).name = (yyvsp[-1].name);
3076  (yyval.parameter).semantic = (yyvsp[0].colon_attribute).semantic;
3077  (yyval.parameter).reg_reservation = (yyvsp[0].colon_attribute).reg_reservation;
3078  }
3079 #line 3080 "hlsl.tab.c" /* yacc.c:1646 */
3080  break;
3081 
3082  case 39:
3083 #line 1409 "hlsl.y" /* yacc.c:1646 */
3084  {
3085  (yyval.modifiers) = 0;
3086  }
3087 #line 3088 "hlsl.tab.c" /* yacc.c:1646 */
3088  break;
3089 
3090  case 40:
3091 #line 1413 "hlsl.y" /* yacc.c:1646 */
3092  {
3093  if ((yyvsp[-1].modifiers) & (yyvsp[0].modifiers))
3094  {
3095  hlsl_report_message(hlsl_ctx.source_file, (yylsp[0]).first_line, (yylsp[0]).first_column,
3096  HLSL_LEVEL_ERROR, "duplicate input-output modifiers");
3097  return 1;
3098  }
3099  (yyval.modifiers) = (yyvsp[-1].modifiers) | (yyvsp[0].modifiers);
3100  }
3101 #line 3102 "hlsl.tab.c" /* yacc.c:1646 */
3102  break;
3103 
3104  case 41:
3105 #line 1424 "hlsl.y" /* yacc.c:1646 */
3106  {
3107  (yyval.modifiers) = HLSL_MODIFIER_IN;
3108  }
3109 #line 3110 "hlsl.tab.c" /* yacc.c:1646 */
3110  break;
3111 
3112  case 42:
3113 #line 1428 "hlsl.y" /* yacc.c:1646 */
3114  {
3115  (yyval.modifiers) = HLSL_MODIFIER_OUT;
3116  }
3117 #line 3118 "hlsl.tab.c" /* yacc.c:1646 */
3118  break;
3119 
3120  case 43:
3121 #line 1432 "hlsl.y" /* yacc.c:1646 */
3122  {
3124  }
3125 #line 3126 "hlsl.tab.c" /* yacc.c:1646 */
3126  break;
3127 
3128  case 44:
3129 #line 1437 "hlsl.y" /* yacc.c:1646 */
3130  {
3131  (yyval.type) = (yyvsp[0].type);
3132  }
3133 #line 3134 "hlsl.tab.c" /* yacc.c:1646 */
3134  break;
3135 
3136  case 45:
3137 #line 1441 "hlsl.y" /* yacc.c:1646 */
3138  {
3139  if ((yyvsp[-3].type)->type != HLSL_CLASS_SCALAR)
3140  {
3141  hlsl_message("Line %u: vectors of non-scalar types are not allowed.\n",
3142  hlsl_ctx.line_no);
3144  return 1;
3145  }
3146  if ((yyvsp[-1].intval) < 1 || (yyvsp[-1].intval) > 4)
3147  {
3148  hlsl_message("Line %u: vector size must be between 1 and 4.\n",
3149  hlsl_ctx.line_no);
3151  return 1;
3152  }
3153 
3154  (yyval.type) = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, (yyvsp[-3].type)->base_type, (yyvsp[-1].intval), 1);
3155  }
3156 #line 3157 "hlsl.tab.c" /* yacc.c:1646 */
3157  break;
3158 
3159  case 46:
3160 #line 1460 "hlsl.y" /* yacc.c:1646 */
3161  {
3162  if ((yyvsp[-5].type)->type != HLSL_CLASS_SCALAR)
3163  {
3164  hlsl_message("Line %u: matrices of non-scalar types are not allowed.\n",
3165  hlsl_ctx.line_no);
3167  return 1;
3168  }
3169  if ((yyvsp[-3].intval) < 1 || (yyvsp[-3].intval) > 4 || (yyvsp[-1].intval) < 1 || (yyvsp[-1].intval) > 4)
3170  {
3171  hlsl_message("Line %u: matrix dimensions must be between 1 and 4.\n",
3172  hlsl_ctx.line_no);
3174  return 1;
3175  }
3176 
3177  (yyval.type) = new_hlsl_type(NULL, HLSL_CLASS_MATRIX, (yyvsp[-5].type)->base_type, (yyvsp[-3].intval), (yyvsp[-1].intval));
3178  }
3179 #line 3180 "hlsl.tab.c" /* yacc.c:1646 */
3180  break;
3181 
3182  case 47:
3183 #line 1480 "hlsl.y" /* yacc.c:1646 */
3184  {
3186  }
3187 #line 3188 "hlsl.tab.c" /* yacc.c:1646 */
3188  break;
3189 
3190  case 48:
3191 #line 1484 "hlsl.y" /* yacc.c:1646 */
3192  {
3194  (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_GENERIC;
3195  }
3196 #line 3197 "hlsl.tab.c" /* yacc.c:1646 */
3197  break;
3198 
3199  case 49:
3200 #line 1489 "hlsl.y" /* yacc.c:1646 */
3201  {
3203  (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_1D;
3204  }
3205 #line 3206 "hlsl.tab.c" /* yacc.c:1646 */
3206  break;
3207 
3208  case 50:
3209 #line 1494 "hlsl.y" /* yacc.c:1646 */
3210  {
3212  (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_2D;
3213  }
3214 #line 3215 "hlsl.tab.c" /* yacc.c:1646 */
3215  break;
3216 
3217  case 51:
3218 #line 1499 "hlsl.y" /* yacc.c:1646 */
3219  {
3221  (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_3D;
3222  }
3223 #line 3224 "hlsl.tab.c" /* yacc.c:1646 */
3224  break;
3225 
3226  case 52:
3227 #line 1504 "hlsl.y" /* yacc.c:1646 */
3228  {
3229  (yyval.type) = new_hlsl_type(d3dcompiler_strdup("samplerCUBE"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
3230  (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_CUBE;
3231  }
3232 #line 3233 "hlsl.tab.c" /* yacc.c:1646 */
3233  break;
3234 
3235  case 53:
3236 #line 1509 "hlsl.y" /* yacc.c:1646 */
3237  {
3238  struct hlsl_type *type;
3239 
3240  type = get_type(hlsl_ctx.cur_scope, (yyvsp[0].name), TRUE);
3241  (yyval.type) = type;
3242  d3dcompiler_free((yyvsp[0].name));
3243  }
3244 #line 3245 "hlsl.tab.c" /* yacc.c:1646 */
3245  break;
3246 
3247  case 54:
3248 #line 1517 "hlsl.y" /* yacc.c:1646 */
3249  {
3250  struct hlsl_type *type;
3251 
3252  type = get_type(hlsl_ctx.cur_scope, (yyvsp[0].name), TRUE);
3253  if (type->type != HLSL_CLASS_STRUCT)
3254  {
3255  hlsl_message("Line %u: redefining %s as a structure.\n",
3256  hlsl_ctx.line_no, (yyvsp[0].name));
3258  }
3259  else
3260  {
3261  (yyval.type) = type;
3262  }
3263  d3dcompiler_free((yyvsp[0].name));
3264  }
3265 #line 3266 "hlsl.tab.c" /* yacc.c:1646 */
3266  break;
3267 
3268  case 57:
3269 #line 1537 "hlsl.y" /* yacc.c:1646 */
3270  {
3271  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3272  if (!(yyval.list))
3273  {
3274  ERR("Out of memory\n");
3275  return -1;
3276  }
3277  list_init((yyval.list));
3278  }
3279 #line 3280 "hlsl.tab.c" /* yacc.c:1646 */
3280  break;
3281 
3282  case 58:
3283 #line 1548 "hlsl.y" /* yacc.c:1646 */
3284  {
3285  struct source_location loc;
3286 
3287  set_location(&loc, &(yylsp[-4]));
3288  if (!add_typedef((yyvsp[-3].modifiers), (yyvsp[-2].type), (yyvsp[-1].list), &loc))
3289  return 1;
3290  }
3291 #line 3292 "hlsl.tab.c" /* yacc.c:1646 */
3292  break;
3293 
3294  case 59:
3295 #line 1556 "hlsl.y" /* yacc.c:1646 */
3296  {
3297  struct source_location loc;
3298 
3299  set_location(&loc, &(yylsp[-3]));
3300  if (!add_typedef(0, (yyvsp[-2].type), (yyvsp[-1].list), &loc))
3301  return 1;
3302  }
3303 #line 3304 "hlsl.tab.c" /* yacc.c:1646 */
3304  break;
3305 
3306  case 60:
3307 #line 1565 "hlsl.y" /* yacc.c:1646 */
3308  {
3309  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3310  list_init((yyval.list));
3311  list_add_head((yyval.list), &(yyvsp[0].variable_def)->entry);
3312  }
3313 #line 3314 "hlsl.tab.c" /* yacc.c:1646 */
3314  break;
3315 
3316  case 61:
3317 #line 1571 "hlsl.y" /* yacc.c:1646 */
3318  {
3319  (yyval.list) = (yyvsp[-2].list);
3320  list_add_tail((yyval.list), &(yyvsp[0].variable_def)->entry);
3321  }
3322 #line 3323 "hlsl.tab.c" /* yacc.c:1646 */
3323  break;
3324 
3325  case 62:
3326 #line 1577 "hlsl.y" /* yacc.c:1646 */
3327  {
3328  (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def)));
3329  set_location(&(yyval.variable_def)->loc, &(yylsp[-1]));
3330  (yyval.variable_def)->name = (yyvsp[-1].name);
3331  (yyval.variable_def)->array_size = (yyvsp[0].intval);
3332  }
3333 #line 3334 "hlsl.tab.c" /* yacc.c:1646 */
3334  break;
3335 
3336  case 63:
3337 #line 1585 "hlsl.y" /* yacc.c:1646 */
3338  {
3339  (yyval.list) = declare_vars((yyvsp[-2].type), (yyvsp[-3].modifiers), (yyvsp[-1].list));
3340  }
3341 #line 3342 "hlsl.tab.c" /* yacc.c:1646 */
3342  break;
3343 
3344  case 64:
3345 #line 1590 "hlsl.y" /* yacc.c:1646 */
3346  {
3347  (yyval.list) = NULL;
3348  }
3349 #line 3350 "hlsl.tab.c" /* yacc.c:1646 */
3350  break;
3351 
3352  case 65:
3353 #line 1594 "hlsl.y" /* yacc.c:1646 */
3354  {
3355  (yyval.list) = (yyvsp[0].list);
3356  }
3357 #line 3358 "hlsl.tab.c" /* yacc.c:1646 */
3358  break;
3359 
3360  case 66:
3361 #line 1599 "hlsl.y" /* yacc.c:1646 */
3362  {
3363  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3364  list_init((yyval.list));
3365  list_add_head((yyval.list), &(yyvsp[0].variable_def)->entry);
3366  }
3367 #line 3368 "hlsl.tab.c" /* yacc.c:1646 */
3368  break;
3369 
3370  case 67:
3371 #line 1605 "hlsl.y" /* yacc.c:1646 */
3372  {
3373  (yyval.list) = (yyvsp[-2].list);
3374  list_add_tail((yyval.list), &(yyvsp[0].variable_def)->entry);
3375  }
3376 #line 3377 "hlsl.tab.c" /* yacc.c:1646 */
3377  break;
3378 
3379  case 68:
3380 #line 1611 "hlsl.y" /* yacc.c:1646 */
3381  {
3382  (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def)));
3383  set_location(&(yyval.variable_def)->loc, &(yylsp[-2]));
3384  (yyval.variable_def)->name = (yyvsp[-2].name);
3385  (yyval.variable_def)->array_size = (yyvsp[-1].intval);
3386  (yyval.variable_def)->semantic = (yyvsp[0].colon_attribute).semantic;
3387  (yyval.variable_def)->reg_reservation = (yyvsp[0].colon_attribute).reg_reservation;
3388  }
3389 #line 3390 "hlsl.tab.c" /* yacc.c:1646 */
3390  break;
3391 
3392  case 69:
3393 #line 1620 "hlsl.y" /* yacc.c:1646 */
3394  {
3395  TRACE("Declaration with initializer.\n");
3396  (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def)));
3397  set_location(&(yyval.variable_def)->loc, &(yylsp[-4]));
3398  (yyval.variable_def)->name = (yyvsp[-4].name);
3399  (yyval.variable_def)->array_size = (yyvsp[-3].intval);
3400  (yyval.variable_def)->semantic = (yyvsp[-2].colon_attribute).semantic;
3401  (yyval.variable_def)->reg_reservation = (yyvsp[-2].colon_attribute).reg_reservation;
3402  (yyval.variable_def)->initializer = (yyvsp[0].list);
3403  }
3404 #line 3405 "hlsl.tab.c" /* yacc.c:1646 */
3405  break;
3406 
3407  case 70:
3408 #line 1632 "hlsl.y" /* yacc.c:1646 */
3409  {
3410  (yyval.intval) = 0;
3411  }
3412 #line 3413 "hlsl.tab.c" /* yacc.c:1646 */
3413  break;
3414 
3415  case 71:
3416 #line 1636 "hlsl.y" /* yacc.c:1646 */
3417  {
3418  FIXME("Array.\n");
3419  (yyval.intval) = 0;
3420  free_instr((yyvsp[-1].instr));
3421  }
3422 #line 3423 "hlsl.tab.c" /* yacc.c:1646 */
3423  break;
3424 
3425  case 72:
3426 #line 1643 "hlsl.y" /* yacc.c:1646 */
3427  {
3428  (yyval.modifiers) = 0;
3429  }
3430 #line 3431 "hlsl.tab.c" /* yacc.c:1646 */
3431  break;
3432 
3433  case 73:
3434 #line 1647 "hlsl.y" /* yacc.c:1646 */
3435  {
3436  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_EXTERN, &(yylsp[-1]));
3437  }
3438 #line 3439 "hlsl.tab.c" /* yacc.c:1646 */
3439  break;
3440 
3441  case 74:
3442 #line 1651 "hlsl.y" /* yacc.c:1646 */
3443  {
3444  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_NOINTERPOLATION, &(yylsp[-1]));
3445  }
3446 #line 3447 "hlsl.tab.c" /* yacc.c:1646 */
3447  break;
3448 
3449  case 75:
3450 #line 1655 "hlsl.y" /* yacc.c:1646 */
3451  {
3452  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_PRECISE, &(yylsp[-1]));
3453  }
3454 #line 3455 "hlsl.tab.c" /* yacc.c:1646 */
3455  break;
3456 
3457  case 76:
3458 #line 1659 "hlsl.y" /* yacc.c:1646 */
3459  {
3460  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_SHARED, &(yylsp[-1]));
3461  }
3462 #line 3463 "hlsl.tab.c" /* yacc.c:1646 */
3463  break;
3464 
3465  case 77:
3466 #line 1663 "hlsl.y" /* yacc.c:1646 */
3467  {
3468  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_GROUPSHARED, &(yylsp[-1]));
3469  }
3470 #line 3471 "hlsl.tab.c" /* yacc.c:1646 */
3471  break;
3472 
3473  case 78:
3474 #line 1667 "hlsl.y" /* yacc.c:1646 */
3475  {
3476  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_STATIC, &(yylsp[-1]));
3477  }
3478 #line 3479 "hlsl.tab.c" /* yacc.c:1646 */
3479  break;
3480 
3481  case 79:
3482 #line 1671 "hlsl.y" /* yacc.c:1646 */
3483  {
3484  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_UNIFORM, &(yylsp[-1]));
3485  }
3486 #line 3487 "hlsl.tab.c" /* yacc.c:1646 */
3487  break;
3488 
3489  case 80:
3490 #line 1675 "hlsl.y" /* yacc.c:1646 */
3491  {
3492  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_VOLATILE, &(yylsp[-1]));
3493  }
3494 #line 3495 "hlsl.tab.c" /* yacc.c:1646 */
3495  break;
3496 
3497  case 81:
3498 #line 1679 "hlsl.y" /* yacc.c:1646 */
3499  {
3500  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_CONST, &(yylsp[-1]));
3501  }
3502 #line 3503 "hlsl.tab.c" /* yacc.c:1646 */
3503  break;
3504 
3505  case 82:
3506 #line 1683 "hlsl.y" /* yacc.c:1646 */
3507  {
3508  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_ROW_MAJOR, &(yylsp[-1]));
3509  }
3510 #line 3511 "hlsl.tab.c" /* yacc.c:1646 */
3511  break;
3512 
3513  case 83:
3514 #line 1687 "hlsl.y" /* yacc.c:1646 */
3515  {
3516  (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_COLUMN_MAJOR, &(yylsp[-1]));
3517  }
3518 #line 3519 "hlsl.tab.c" /* yacc.c:1646 */
3519  break;
3520 
3521  case 84:
3522 #line 1692 "hlsl.y" /* yacc.c:1646 */
3523  {
3524  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3525  list_init((yyval.list));
3526  list_add_head((yyval.list), &(yyvsp[0].instr)->entry);
3527  }
3528 #line 3529 "hlsl.tab.c" /* yacc.c:1646 */
3529  break;
3530 
3531  case 85:
3532 #line 1698 "hlsl.y" /* yacc.c:1646 */
3533  {
3534  (yyval.list) = (yyvsp[-1].list);
3535  }
3536 #line 3537 "hlsl.tab.c" /* yacc.c:1646 */
3537  break;
3538 
3539  case 86:
3540 #line 1702 "hlsl.y" /* yacc.c:1646 */
3541  {
3542  (yyval.list) = (yyvsp[-2].list);
3543  }
3544 #line 3545 "hlsl.tab.c" /* yacc.c:1646 */
3545  break;
3546 
3547  case 87:
3548 #line 1707 "hlsl.y" /* yacc.c:1646 */
3549  {
3550  (yyval.instr) = (yyvsp[0].instr);
3551  }
3552 #line 3553 "hlsl.tab.c" /* yacc.c:1646 */
3553  break;
3554 
3555  case 88:
3556 #line 1712 "hlsl.y" /* yacc.c:1646 */
3557  {
3558  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3559  list_init((yyval.list));
3560  list_add_head((yyval.list), &(yyvsp[0].instr)->entry);
3561  }
3562 #line 3563 "hlsl.tab.c" /* yacc.c:1646 */
3563  break;
3564 
3565  case 89:
3566 #line 1718 "hlsl.y" /* yacc.c:1646 */
3567  {
3568  (yyval.list) = (yyvsp[-2].list);
3569  list_add_tail((yyval.list), &(yyvsp[0].instr)->entry);
3570  }
3571 #line 3572 "hlsl.tab.c" /* yacc.c:1646 */
3572  break;
3573 
3574  case 90:
3575 #line 1724 "hlsl.y" /* yacc.c:1646 */
3576  {
3577  (yyval.boolval) = TRUE;
3578  }
3579 #line 3580 "hlsl.tab.c" /* yacc.c:1646 */
3580  break;
3581 
3582  case 91:
3583 #line 1728 "hlsl.y" /* yacc.c:1646 */
3584  {
3585  (yyval.boolval) = FALSE;
3586  }
3587 #line 3588 "hlsl.tab.c" /* yacc.c:1646 */
3588  break;
3589 
3590  case 92:
3591 #line 1733 "hlsl.y" /* yacc.c:1646 */
3592  {
3593  (yyval.list) = (yyvsp[0].list);
3594  }
3595 #line 3596 "hlsl.tab.c" /* yacc.c:1646 */
3596  break;
3597 
3598  case 93:
3599 #line 1737 "hlsl.y" /* yacc.c:1646 */
3600  {
3601  (yyval.list) = (yyvsp[-1].list);
3602  list_move_tail((yyval.list), (yyvsp[0].list));
3603  d3dcompiler_free((yyvsp[0].list));
3604  }
3605 #line 3606 "hlsl.tab.c" /* yacc.c:1646 */
3606  break;
3607 
3608  case 100:
3609 #line 1752 "hlsl.y" /* yacc.c:1646 */
3610  {
3611  struct hlsl_ir_jump *jump = d3dcompiler_alloc(sizeof(*jump));
3612  if (!jump)
3613  {
3614  ERR("Out of memory\n");
3615  return -1;
3616  }
3617  jump->node.type = HLSL_IR_JUMP;
3618  set_location(&jump->node.loc, &(yylsp[-2]));
3619  jump->type = HLSL_IR_JUMP_RETURN;
3620  jump->node.data_type = (yyvsp[-1].instr)->data_type;
3621  jump->return_value = (yyvsp[-1].instr);
3622 
3623  FIXME("Check for valued return on void function.\n");
3624  FIXME("Implicit conversion to the return type if needed, "
3625  "error out if conversion not possible.\n");
3626 
3627  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3628  list_init((yyval.list));
3629  list_add_tail((yyval.list), &jump->node.entry);
3630  }
3631 #line 3632 "hlsl.tab.c" /* yacc.c:1646 */
3632  break;
3633 
3634  case 101:
3635 #line 1775 "hlsl.y" /* yacc.c:1646 */
3636  {
3637  struct hlsl_ir_if *instr = d3dcompiler_alloc(sizeof(*instr));
3638  if (!instr)
3639  {
3640  ERR("Out of memory\n");
3641  return -1;
3642  }
3643  instr->node.type = HLSL_IR_IF;
3644  set_location(&instr->node.loc, &(yylsp[-4]));
3645  instr->condition = (yyvsp[-2].instr);
3646  instr->then_instrs = (yyvsp[0].if_body).then_instrs;
3647  instr->else_instrs = (yyvsp[0].if_body).else_instrs;
3648  if ((yyvsp[-2].instr)->data_type->dimx > 1 || (yyvsp[-2].instr)->data_type->dimy > 1)
3649  {
3650  hlsl_report_message(instr->node.loc.file, instr->node.loc.line,
3651  instr->node.loc.col, HLSL_LEVEL_ERROR,
3652  "if condition requires a scalar");
3653  }
3654  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3655  list_init((yyval.list));
3656  list_add_head((yyval.list), &instr->node.entry);
3657  }
3658 #line 3659 "hlsl.tab.c" /* yacc.c:1646 */
3659  break;
3660 
3661  case 102:
3662 #line 1799 "hlsl.y" /* yacc.c:1646 */
3663  {
3664  (yyval.if_body).then_instrs = (yyvsp[0].list);
3665  (yyval.if_body).else_instrs = NULL;
3666  }
3667 #line 3668 "hlsl.tab.c" /* yacc.c:1646 */
3668  break;
3669 
3670  case 103:
3671 #line 1804 "hlsl.y" /* yacc.c:1646 */
3672  {
3673  (yyval.if_body).then_instrs = (yyvsp[-2].list);
3674  (yyval.if_body).else_instrs = (yyvsp[0].list);
3675  }
3676 #line 3677 "hlsl.tab.c" /* yacc.c:1646 */
3677  break;
3678 
3679  case 104:
3680 #line 1810 "hlsl.y" /* yacc.c:1646 */
3681  {
3682  struct source_location loc;
3683  struct list *cond = d3dcompiler_alloc(sizeof(*cond));
3684 
3685  if (!cond)
3686  {
3687  ERR("Out of memory.\n");
3688  return -1;
3689  }
3690  list_init(cond);
3691  list_add_head(cond, &(yyvsp[-2].instr)->entry);
3692  set_location(&loc, &(yylsp[-4]));
3693  (yyval.list) = create_loop(LOOP_WHILE, NULL, cond, NULL, (yyvsp[0].list), &loc);
3694  }
3695 #line 3696 "hlsl.tab.c" /* yacc.c:1646 */
3696  break;
3697 
3698  case 105:
3699 #line 1825 "hlsl.y" /* yacc.c:1646 */
3700  {
3701  struct source_location loc;
3702  struct list *cond = d3dcompiler_alloc(sizeof(*cond));
3703 
3704  if (!cond)
3705  {
3706  ERR("Out of memory.\n");
3707  return -1;
3708  }
3709  list_init(cond);
3710  list_add_head(cond, &(yyvsp[-2].instr)->entry);
3711  set_location(&loc, &(yylsp[-6]));
3712  (yyval.list) = create_loop(LOOP_DO_WHILE, NULL, cond, NULL, (yyvsp[-5].list), &loc);
3713  }
3714 #line 3715 "hlsl.tab.c" /* yacc.c:1646 */
3715  break;
3716 
3717  case 106:
3718 #line 1840 "hlsl.y" /* yacc.c:1646 */
3719  {
3720  struct source_location loc;
3721 
3722  set_location(&loc, &(yylsp[-7]));
3723  (yyval.list) = create_loop(LOOP_FOR, (yyvsp[-4].list), (yyvsp[-3].list), (yyvsp[-2].instr), (yyvsp[0].list), &loc);
3724  pop_scope(&hlsl_ctx);
3725  }
3726 #line 3727 "hlsl.tab.c" /* yacc.c:1646 */
3727  break;
3728 
3729  case 107:
3730 #line 1848 "hlsl.y" /* yacc.c:1646 */
3731  {
3732  struct source_location loc;
3733 
3734  set_location(&loc, &(yylsp[-7]));
3735  if (!(yyvsp[-4].list))
3737  "no expressions in for loop initializer");
3738  (yyval.list) = create_loop(LOOP_FOR, (yyvsp[-4].list), (yyvsp[-3].list), (yyvsp[-2].instr), (yyvsp[0].list), &loc);
3739  pop_scope(&hlsl_ctx);
3740  }
3741 #line 3742 "hlsl.tab.c" /* yacc.c:1646 */
3742  break;
3743 
3744  case 108:
3745 #line 1860 "hlsl.y" /* yacc.c:1646 */
3746  {
3747  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3748  list_init((yyval.list));
3749  }
3750 #line 3751 "hlsl.tab.c" /* yacc.c:1646 */
3751  break;
3752 
3753  case 109:
3754 #line 1865 "hlsl.y" /* yacc.c:1646 */
3755  {
3756  (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list)));
3757  list_init((yyval.list));
3758  if ((yyvsp[-1].instr))
3759  list_add_head((yyval.list), &(yyvsp[-1].instr)->entry);
3760  }
3761 #line 3762 "hlsl.tab.c" /* yacc.c:1646 */
3762  break;
3763 
3764  case 110:
3765 #line 1873 "hlsl.y" /* yacc.c:1646 */
3766  {
3767  struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c));
3768  if (!c)
3769  {
3770  ERR("Out of memory.\n");
3771  return -1;
3772  }
3773  c->node.type = HLSL_IR_CONSTANT;
3774  set_location(&c->node.loc, &yylloc);
3775  c->node.data_type = new_hlsl_type(d3dcompiler_strdup("float"), HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1);
3776  c->v.value.f[0] = (yyvsp[0].floatval);
3777  (yyval.instr) = &c->node;
3778  }
3779 #line 3780 "hlsl.tab.c" /* yacc.c:1646 */
3780  break;
3781 
3782  case 111:
3783 #line 1887 "hlsl.y" /* yacc.c:1646 */
3784  {
3785  struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c));
3786  if (!c)
3787  {
3788  ERR("Out of memory.\n");
3789  return -1;
3790  }
3791  c->node.type = HLSL_IR_CONSTANT;
3792  set_location(&c->node.loc, &yylloc);
3793  c->node.data_type = new_hlsl_type(d3dcompiler_strdup("int"), HLSL_CLASS_SCALAR, HLSL_TYPE_INT, 1, 1);
3794  c->v.value.i[0] = (yyvsp[0].intval);
3795  (yyval.instr) = &c->node;
3796  }
3797 #line 3798 "hlsl.tab.c" /* yacc.c:1646 */
3798  break;
3799 
3800  case 112:
3801 #line 1901 "hlsl.y" /* yacc.c:1646 */
3802  {
3803  struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c));
3804  if (!c)
3805  {
3806  ERR("Out of memory.\n");
3807  return -1;
3808  }
3809  c->node.type = HLSL_IR_CONSTANT;
3810  set_location(&c->node.loc, &yylloc);
3811  c->node.data_type = new_hlsl_type(d3dcompiler_strdup("bool"), HLSL_CLASS_SCALAR, HLSL_TYPE_BOOL, 1, 1);
3812  c->v.value.b[0] = (yyvsp[0].boolval);
3813  (yyval.instr) = &c->node;
3814  }
3815 #line 3816 "hlsl.tab.c" /* yacc.c:1646 */
3816  break;
3817 
3818  case 113:
3819 #line 1915 "hlsl.y" /* yacc.c:1646 */
3820  {
3821  struct hlsl_ir_deref *deref = new_var_deref((yyvsp[0].var));
3822  if (deref)
3823  {
3824  (yyval.instr) = &deref->node;
3825  set_location(&(yyval.instr)->loc, &(yylsp[0]));
3826  }
3827  else
3828  (yyval.instr) = NULL;
3829  }
3830 #line 3831 "hlsl.tab.c" /* yacc.c:1646 */
3831  break;
3832 
3833  case 114:
3834 #line 1926 "hlsl.y" /* yacc.c:1646 */
3835  {
3836  (yyval.instr) = (yyvsp[-1].instr);
3837  }
3838 #line 3839 "hlsl.tab.c" /* yacc.c:1646 */
3839  break;
3840 
3841  case 115:
3842 #line 1931 "hlsl.y" /* yacc.c:1646 */
3843  {
3844  struct hlsl_ir_var *var;
3845  var = get_variable(hlsl_ctx.cur_scope, (yyvsp[0].name));
3846  if (!var)
3847  {
3848  hlsl_message("Line %d: variable '%s' not declared\n",
3849  hlsl_ctx.line_no, (yyvsp[0].name));
3851  return 1;
3852  }
3853  (yyval.var) = var;
3854  }
3855 #line 3856 "hlsl.tab.c" /* yacc.c:1646 */
3856  break;
3857 
3858  case 116:
3859 #line 1945 "hlsl.y" /* yacc.c:1646 */
3860  {
3861  (yyval.instr) = (yyvsp[0].instr);
3862  }
3863 #line 3864 "hlsl.tab.c" /* yacc.c:1646 */
3864  break;
3865 
3866  case 117:
3867 #line 1949 "hlsl.y" /* yacc.c:1646 */
3868  {
3869  struct hlsl_ir_node *operands[3];
3870  struct source_location loc;
3871 
3872  set_location(&loc, &(yylsp[0]));
3873  if ((yyvsp[-1].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
3874  {
3876  "modifying a const expression");
3877  return 1;
3878  }
3879  operands[0] = (yyvsp[-1].instr);
3880  operands[1] = operands[2] = NULL;
3881  (yyval.instr) = &new_expr(HLSL_IR_UNOP_POSTINC, operands, &loc)->node;
3882  /* Post increment/decrement expressions are considered const */
3883  (yyval.instr)->data_type = clone_hlsl_type((yyval.instr)->data_type);
3884  (yyval.instr)->data_type->modifiers |= HLSL_MODIFIER_CONST;
3885  }
3886 #line 3887 "hlsl.tab.c" /* yacc.c:1646 */
3887  break;
3888 
3889  case 118:
3890 #line 1968 "hlsl.y" /* yacc.c:1646 */
3891  {
3892  struct hlsl_ir_node *operands[3];
3893  struct source_location loc;
3894 
3895  set_location(&loc, &(yylsp[0]));
3896  if ((yyvsp[-1].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
3897  {
3899  "modifying a const expression");
3900  return 1;
3901  }
3902  operands[0] = (yyvsp[-1].instr);
3903  operands[1] = operands[2] = NULL;
3904  (yyval.instr) = &new_expr(HLSL_IR_UNOP_POSTDEC, operands, &loc)->node;
3905  /* Post increment/decrement expressions are considered const */
3906  (yyval.instr)->data_type = clone_hlsl_type((yyval.instr)->data_type);
3907  (yyval.instr)->data_type->modifiers |= HLSL_MODIFIER_CONST;
3908  }
3909 #line 3910 "hlsl.tab.c" /* yacc.c:1646 */
3910  break;
3911 
3912  case 119:
3913 #line 1987 "hlsl.y" /* yacc.c:1646 */
3914  {
3915  struct source_location loc;
3916 
3917  set_location(&loc, &(yylsp[-1]));
3918  if ((yyvsp[-2].instr)->data_type->type == HLSL_CLASS_STRUCT)
3919  {
3920  struct hlsl_type *type = (yyvsp[-2].instr)->data_type;
3921  struct hlsl_struct_field *field;
3922 
3923  (yyval.instr) = NULL;
3924  LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
3925  {
3926  if (!strcmp((yyvsp[0].name), field->name))
3927  {
3928  struct hlsl_ir_deref *deref = new_record_deref((yyvsp[-2].instr), field);
3929 
3930  if (!deref)
3931  {
3932  ERR("Out of memory\n");
3933  return -1;
3934  }
3935  deref->node.loc = loc;
3936  (yyval.instr) = &deref->node;
3937  break;
3938  }
3939  }
3940  if (!(yyval.instr))
3941  {
3943  "invalid subscript %s", debugstr_a((yyvsp[0].name)));
3944  return 1;
3945  }
3946  }
3947  else if ((yyvsp[-2].instr)->data_type->type <= HLSL_CLASS_LAST_NUMERIC)
3948  {
3949  struct hlsl_ir_swizzle *swizzle;
3950 
3951  swizzle = get_swizzle((yyvsp[-2].instr), (yyvsp[0].name), &loc);
3952  if (!swizzle)
3953  {
3955  "invalid swizzle %s", debugstr_a((yyvsp[0].name)));
3956  return 1;
3957  }
3958  (yyval.instr) = &swizzle->node;
3959  }
3960  else
3961  {
3963  "invalid subscript %s", debugstr_a((yyvsp[0].name)));
3964  return 1;
3965  }
3966  }
3967 #line 3968 "hlsl.tab.c" /* yacc.c:1646 */
3968  break;
3969 
3970  case 120:
3971 #line 2041 "hlsl.y" /* yacc.c:1646 */
3972  {
3973  /* This may be an array dereference or a vector/matrix
3974  * subcomponent access.
3975  * We store it as an array dereference in any case. */
3976  struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref));
3977  struct hlsl_type *expr_type = (yyvsp[-3].instr)->data_type;
3978  struct source_location loc;
3979 
3980  TRACE("Array dereference from type %s\n", debug_hlsl_type(expr_type));
3981  if (!deref)
3982  {
3983  ERR("Out of memory\n");
3984  return -1;
3985  }
3986  deref->node.type = HLSL_IR_DEREF;
3987  set_location(&loc, &(yylsp[-2]));
3988  deref->node.loc = loc;
3989  if (expr_type->type == HLSL_CLASS_ARRAY)
3990  {
3991  deref->node.data_type = expr_type->e.array.type;
3992  }
3993  else if (expr_type->type == HLSL_CLASS_MATRIX)
3994  {
3995  deref->node.data_type = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, expr_type->base_type, expr_type->dimx, 1);
3996  }
3997  else if (expr_type->type == HLSL_CLASS_VECTOR)
3998  {
3999  deref->node.data_type = new_hlsl_type(NULL, HLSL_CLASS_SCALAR, expr_type->base_type, 1, 1);
4000  }
4001  else
4002  {
4003  if (expr_type->type == HLSL_CLASS_SCALAR)
4005  "array-indexed expression is scalar");
4006  else
4008  "expression is not array-indexable");
4009  d3dcompiler_free(deref);
4010  free_instr((yyvsp[-3].instr));
4011  free_instr((yyvsp[-1].instr));
4012  return 1;
4013  }
4014  if ((yyvsp[-1].instr)->data_type->type != HLSL_CLASS_SCALAR)
4015  {
4017  "array index is not scalar");
4018  d3dcompiler_free(deref);
4019  free_instr((yyvsp[-3].instr));
4020  free_instr((yyvsp[-1].instr));
4021  return 1;
4022  }
4023  deref->type = HLSL_IR_DEREF_ARRAY;
4024  deref->v.array.array = (yyvsp[-3].instr);
4025  deref->v.array.index = (yyvsp[-1].instr);
4026 
4027  (yyval.instr) = &deref->node;
4028  }
4029 #line 4030 "hlsl.tab.c" /* yacc.c:1646 */
4030  break;
4031 
4032  case 121:
4033 #line 2101 "hlsl.y" /* yacc.c:1646 */
4034  {
4035  struct hlsl_ir_constructor *constructor;
4036 
4037  TRACE("%s constructor.\n", debug_hlsl_type((yyvsp[-3].type)));
4038  if ((yyvsp[-4].modifiers))
4039  {
4040  hlsl_message("Line %u: unexpected modifier in a constructor.\n",
4041  hlsl_ctx.line_no);
4043  return -1;
4044  }
4045  if ((yyvsp[-3].type)->type > HLSL_CLASS_LAST_NUMERIC)
4046  {
4047  hlsl_message("Line %u: constructors are allowed only for numeric data types.\n",
4048  hlsl_ctx.line_no);
4050  return -1;
4051  }
4052  if ((yyvsp[-3].type)->dimx * (yyvsp[-3].type)->dimy != components_count_expr_list((yyvsp[-1].list)))
4053  {
4054  hlsl_message("Line %u: wrong number of components in constructor.\n",
4055  hlsl_ctx.line_no);
4057  return -1;
4058  }
4059 
4060  constructor = d3dcompiler_alloc(sizeof(*constructor));
4061  constructor->node.type = HLSL_IR_CONSTRUCTOR;
4062  set_location(&constructor->node.loc, &(yylsp[-2]));
4063  constructor->node.data_type = (yyvsp[-3].type);
4064  constructor->arguments = (yyvsp[-1].list);
4065 
4066  (yyval.instr) = &constructor->node;
4067  }
4068 #line 4069 "hlsl.tab.c" /* yacc.c:1646 */
4069  break;
4070 
4071  case 122:
4072 #line 2137 "hlsl.y" /* yacc.c:1646 */
4073  {
4074  (yyval.instr) = (yyvsp[0].instr);
4075  }
4076 #line 4077 "hlsl.tab.c" /* yacc.c:1646 */
4077  break;
4078 
4079  case 123:
4080 #line 2141 "hlsl.y" /* yacc.c:1646 */
4081  {
4082  struct hlsl_ir_node *operands[3];
4083  struct source_location loc;
4084 
4085  set_location(&loc, &(yylsp[-1]));
4086  if ((yyvsp[0].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4087  {
4089  "modifying a const expression");
4090  return 1;
4091  }
4092  operands[0] = (yyvsp[0].instr);
4093  operands[1] = operands[2] = NULL;
4094  (yyval.instr) = &new_expr(HLSL_IR_UNOP_PREINC, operands, &loc)->node;
4095  }
4096 #line 4097 "hlsl.tab.c" /* yacc.c:1646 */
4097  break;
4098 
4099  case 124:
4100 #line 2157 "hlsl.y" /* yacc.c:1646 */
4101  {
4102  struct hlsl_ir_node *operands[3];
4103  struct source_location loc;
4104 
4105  set_location(&loc, &(yylsp[-1]));
4106  if ((yyvsp[0].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4107  {
4109  "modifying a const expression");
4110  return 1;
4111  }
4112  operands[0] = (yyvsp[0].instr);
4113  operands[1] = operands[2] = NULL;
4114  (yyval.instr) = &new_expr(HLSL_IR_UNOP_PREDEC, operands, &loc)->node;
4115  }
4116 #line 4117 "hlsl.tab.c" /* yacc.c:1646 */
4117  break;
4118 
4119  case 125:
4120 #line 2173 "hlsl.y" /* yacc.c:1646 */
4121  {
4122  enum hlsl_ir_expr_op ops[] = {0, HLSL_IR_UNOP_NEG,
4124  struct hlsl_ir_node *operands[3];
4125  struct source_location loc;
4126 
4127  if ((yyvsp[-1].unary_op) == UNARY_OP_PLUS)
4128  {
4129  (yyval.instr) = (yyvsp[0].instr);
4130  }
4131  else
4132  {
4133  operands[0] = (yyvsp[0].instr);
4134  operands[1] = operands[2] = NULL;
4135  set_location(&loc, &(yylsp[-1]));
4136  (yyval.instr) = &new_expr(ops[(yyvsp[-1].unary_op)], operands, &loc)->node;
4137  }
4138  }
4139 #line 4140 "hlsl.tab.c" /* yacc.c:1646 */
4140  break;
4141 
4142  case 126:
4143 #line 2193 "hlsl.y" /* yacc.c:1646 */
4144  {
4145  struct hlsl_ir_expr *expr;
4146  struct hlsl_type *src_type = (yyvsp[0].instr)->data_type;
4147  struct hlsl_type *dst_type;
4148  struct source_location loc;
4149 
4150  set_location(&loc, &(yylsp[-3]));
4151  if ((yyvsp[-4].modifiers))
4152  {
4154  "unexpected modifier in a cast");
4155  return 1;
4156  }
4157 
4158  if ((yyvsp[-2].intval))
4159  dst_type = new_array_type((yyvsp[-3].type), (yyvsp[-2].intval));
4160  else
4161  dst_type = (yyvsp[-3].type);
4162 
4163  if (!compatible_data_types(src_type, dst_type))
4164  {
4166  "can't cast from %s to %s",
4167  debug_hlsl_type(src_type), debug_hlsl_type(dst_type));
4168  return 1;
4169  }
4170 
4171  expr = new_cast((yyvsp[0].instr), dst_type, &loc);
4172  (yyval.instr) = expr ? &expr->node : NULL;
4173  }
4174 #line 4175 "hlsl.tab.c" /* yacc.c:1646 */
4175  break;
4176 
4177  case 127:
4178 #line 2225 "hlsl.y" /* yacc.c:1646 */
4179  {
4180  (yyval.unary_op) = UNARY_OP_PLUS;
4181  }
4182 #line 4183 "hlsl.tab.c" /* yacc.c:1646 */
4183  break;
4184 
4185  case 128:
4186 #line 2229 "hlsl.y" /* yacc.c:1646 */
4187  {
4188  (yyval.unary_op) = UNARY_OP_MINUS;
4189  }
4190 #line 4191 "hlsl.tab.c" /* yacc.c:1646 */
4191  break;
4192 
4193  case 129:
4194 #line 2233 "hlsl.y" /* yacc.c:1646 */
4195  {
4196  (yyval.unary_op) = UNARY_OP_LOGICNOT;
4197  }
4198 #line 4199 "hlsl.tab.c" /* yacc.c:1646 */
4199  break;
4200 
4201  case 130:
4202 #line 2237 "hlsl.y" /* yacc.c:1646 */
4203  {
4204  (yyval.unary_op) = UNARY_OP_BITNOT;
4205  }
4206 #line 4207 "hlsl.tab.c" /* yacc.c:1646 */
4207  break;
4208 
4209  case 131:
4210 #line 2242 "hlsl.y" /* yacc.c:1646 */
4211  {
4212  (yyval.instr) = (yyvsp[0].instr);
4213  }
4214 #line 4215 "hlsl.tab.c" /* yacc.c:1646 */
4215  break;
4216 
4217  case 132:
4218 #line 2246 "hlsl.y" /* yacc.c:1646 */
4219  {
4220  struct source_location loc;
4221 
4222  set_location(&loc, &(yylsp[-1]));
4223  (yyval.instr) = &hlsl_mul((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4224  }
4225 #line 4226 "hlsl.tab.c" /* yacc.c:1646 */
4226  break;
4227 
4228  case 133:
4229 #line 2253 "hlsl.y" /* yacc.c:1646 */
4230  {
4231  struct source_location loc;
4232 
4233  set_location(&loc, &(yylsp[-1]));
4234  (yyval.instr) = &hlsl_div((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4235  }
4236 #line 4237 "hlsl.tab.c" /* yacc.c:1646 */
4237  break;
4238 
4239  case 134:
4240 #line 2260 "hlsl.y" /* yacc.c:1646 */
4241  {
4242  struct source_location loc;
4243 
4244  set_location(&loc, &(yylsp[-1]));
4245  (yyval.instr) = &hlsl_mod((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4246  }
4247 #line 4248 "hlsl.tab.c" /* yacc.c:1646 */
4248  break;
4249 
4250  case 135:
4251 #line 2268 "hlsl.y" /* yacc.c:1646 */
4252  {
4253  (yyval.instr) = (yyvsp[0].instr);
4254  }
4255 #line 4256 "hlsl.tab.c" /* yacc.c:1646 */
4256  break;
4257 
4258  case 136:
4259 #line 2272 "hlsl.y" /* yacc.c:1646 */
4260  {
4261  struct source_location loc;
4262 
4263  set_location(&loc, &(yylsp[-1]));
4264  (yyval.instr) = &hlsl_add((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4265  }
4266 #line 4267 "hlsl.tab.c" /* yacc.c:1646 */
4267  break;
4268 
4269  case 137:
4270 #line 2279 "hlsl.y" /* yacc.c:1646 */
4271  {
4272  struct source_location loc;
4273 
4274  set_location(&loc, &(yylsp[-1]));
4275  (yyval.instr) = &hlsl_sub((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4276  }
4277 #line 4278 "hlsl.tab.c" /* yacc.c:1646 */
4278  break;
4279 
4280  case 138:
4281 #line 2287 "hlsl.y" /* yacc.c:1646 */
4282  {
4283  (yyval.instr) = (yyvsp[0].instr);
4284  }
4285 #line 4286 "hlsl.tab.c" /* yacc.c:1646 */
4286  break;
4287 
4288  case 139:
4289 #line 2291 "hlsl.y" /* yacc.c:1646 */
4290  {
4291  FIXME("Left shift\n");
4292  }
4293 #line 4294 "hlsl.tab.c" /* yacc.c:1646 */
4294  break;
4295 
4296  case 140:
4297 #line 2295 "hlsl.y" /* yacc.c:1646 */
4298  {
4299  FIXME("Right shift\n");
4300  }
4301 #line 4302 "hlsl.tab.c" /* yacc.c:1646 */
4302  break;
4303 
4304  case 141:
4305 #line 2300 "hlsl.y" /* yacc.c:1646 */
4306  {
4307  (yyval.instr) = (yyvsp[0].instr);
4308  }
4309 #line 4310 "hlsl.tab.c" /* yacc.c:1646 */
4310  break;
4311 
4312  case 142:
4313 #line 2304 "hlsl.y" /* yacc.c:1646 */
4314  {
4315  struct source_location loc;
4316 
4317  set_location(&loc, &(yylsp[-1]));
4318  (yyval.instr) = &hlsl_lt((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4319  }
4320 #line 4321 "hlsl.tab.c" /* yacc.c:1646 */
4321  break;
4322 
4323  case 143:
4324 #line 2311 "hlsl.y" /* yacc.c:1646 */
4325  {
4326  struct source_location loc;
4327 
4328  set_location(&loc, &(yylsp[-1]));
4329  (yyval.instr) = &hlsl_gt((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4330  }
4331 #line 4332 "hlsl.tab.c" /* yacc.c:1646 */
4332  break;
4333 
4334  case 144:
4335 #line 2318 "hlsl.y" /* yacc.c:1646 */
4336  {
4337  struct source_location loc;
4338 
4339  set_location(&loc, &(yylsp[-1]));
4340  (yyval.instr) = &hlsl_le((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4341  }
4342 #line 4343 "hlsl.tab.c" /* yacc.c:1646 */
4343  break;
4344 
4345  case 145:
4346 #line 2325 "hlsl.y" /* yacc.c:1646 */
4347  {
4348  struct source_location loc;
4349 
4350  set_location(&loc, &(yylsp[-1]));
4351  (yyval.instr) = &hlsl_ge((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4352  }
4353 #line 4354 "hlsl.tab.c" /* yacc.c:1646 */
4354  break;
4355 
4356  case 146:
4357 #line 2333 "hlsl.y" /* yacc.c:1646 */
4358  {
4359  (yyval.instr) = (yyvsp[0].instr);
4360  }
4361 #line 4362 "hlsl.tab.c" /* yacc.c:1646 */
4362  break;
4363 
4364  case 147:
4365 #line 2337 "hlsl.y" /* yacc.c:1646 */
4366  {
4367  struct source_location loc;
4368 
4369  set_location(&loc, &(yylsp[-1]));
4370  (yyval.instr) = &hlsl_eq((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4371  }
4372 #line 4373 "hlsl.tab.c" /* yacc.c:1646 */
4373  break;
4374 
4375  case 148:
4376 #line 2344 "hlsl.y" /* yacc.c:1646 */
4377  {
4378  struct source_location loc;
4379 
4380  set_location(&loc, &(yylsp[-1]));
4381  (yyval.instr) = &hlsl_ne((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node;
4382  }
4383 #line 4384 "hlsl.tab.c" /* yacc.c:1646 */
4384  break;
4385 
4386  case 149:
4387 #line 2352 "hlsl.y" /* yacc.c:1646 */
4388  {
4389  (yyval.instr) = (yyvsp[0].instr);
4390  }
4391 #line 4392 "hlsl.tab.c" /* yacc.c:1646 */
4392  break;
4393 
4394  case 150:
4395 #line 2356 "hlsl.y" /* yacc.c:1646 */
4396  {
4397  FIXME("bitwise AND\n");
4398  }
4399 #line 4400 "hlsl.tab.c" /* yacc.c:1646 */
4400  break;
4401 
4402  case 151:
4403 #line 2361 "hlsl.y" /* yacc.c:1646 */
4404  {
4405  (yyval.instr) = (yyvsp[0].instr);
4406  }
4407 #line 4408 "hlsl.tab.c" /* yacc.c:1646 */
4408  break;
4409 
4410  case 152:
4411 #line 2365 "hlsl.y" /* yacc.c:1646 */
4412  {
4413  FIXME("bitwise XOR\n");
4414  }
4415 #line 4416 "hlsl.tab.c" /* yacc.c:1646 */
4416  break;
4417 
4418  case 153:
4419 #line 2370 "hlsl.y" /* yacc.c:1646 */
4420  {
4421  (yyval.instr) = (yyvsp[0].instr);
4422  }
4423 #line 4424 "hlsl.tab.c" /* yacc.c:1646 */
4424  break;
4425 
4426  case 154:
4427 #line 2374 "hlsl.y" /* yacc.c:1646 */
4428  {
4429  FIXME("bitwise OR\n");
4430  }
4431 #line 4432 "hlsl.tab.c" /* yacc.c:1646 */
4432  break;
4433 
4434  case 155:
4435 #line 2379 "hlsl.y" /* yacc.c:1646 */
4436  {
4437  (yyval.instr) = (yyvsp[0].instr);
4438  }
4439 #line 4440 "hlsl.tab.c" /* yacc.c:1646 */
4440  break;
4441 
4442  case 156:
4443 #line 2383 "hlsl.y" /* yacc.c:1646 */
4444  {
4445  FIXME("logic AND\n");
4446  }
4447 #line 4448 "hlsl.tab.c" /* yacc.c:1646 */
4448  break;
4449 
4450  case 157:
4451 #line 2388 "hlsl.y" /* yacc.c:1646 */
4452  {
4453  (yyval.instr) = (yyvsp[0].instr);
4454  }
4455 #line 4456 "hlsl.tab.c" /* yacc.c:1646 */
4456  break;
4457 
4458  case 158:
4459 #line 2392 "hlsl.y" /* yacc.c:1646 */
4460  {
4461  FIXME("logic OR\n");
4462  }
4463 #line 4464 "hlsl.tab.c" /* yacc.c:1646 */
4464  break;
4465 
4466  case 159:
4467 #line 2397 "hlsl.y" /* yacc.c:1646 */
4468  {
4469  (yyval.instr) = (yyvsp[0].instr);
4470  }
4471 #line 4472 "hlsl.tab.c" /* yacc.c:1646 */
4472  break;
4473 
4474  case 160:
4475 #line 2401 "hlsl.y" /* yacc.c:1646 */
4476  {
4477  FIXME("ternary operator\n");
4478  }
4479 #line 4480 "hlsl.tab.c" /* yacc.c:1646 */
4480  break;
4481 
4482  case 161:
4483 #line 2406 "hlsl.y" /* yacc.c:1646 */
4484  {
4485  (yyval.instr) = (yyvsp[0].instr);
4486  }
4487 #line 4488 "hlsl.tab.c" /* yacc.c:1646 */
4488  break;
4489 
4490  case 162:
4491 #line 2410 "hlsl.y" /* yacc.c:1646 */
4492  {
4493  struct source_location loc;
4494 
4495  set_location(&loc, &(yylsp[-1]));
4496  if ((yyvsp[-2].instr)->data_type->modifiers & HLSL_MODIFIER_CONST)
4497  {
4499  "l-value is const");
4500  return 1;
4501  }
4502  (yyval.instr) = make_assignment((yyvsp[-2].instr), (yyvsp[-1].assign_op), BWRITERSP_WRITEMASK_ALL, (yyvsp[0].instr));
4503  if (!(yyval.instr))
4504  return 1;
4505  (yyval.instr)->loc = loc;
4506  }
4507 #line 4508 "hlsl.tab.c" /* yacc.c:1646 */
4508  break;
4509 
4510  case 163:
4511 #line 2427 "hlsl.y" /* yacc.c:1646 */
4512  {
4513  (yyval.assign_op) = ASSIGN_OP_ASSIGN;
4514  }
4515 #line 4516 "hlsl.tab.c" /* yacc.c:1646 */
4516  break;
4517 
4518  case 164:
4519 #line 2431 "hlsl.y" /* yacc.c:1646 */
4520  {
4521  (yyval.assign_op) = ASSIGN_OP_ADD;
4522  }
4523 #line 4524 "hlsl.tab.c" /* yacc.c:1646 */
4524  break;
4525 
4526  case 165:
4527 #line 2435 "hlsl.y" /* yacc.c:1646 */
4528  {
4529  (yyval.assign_op) = ASSIGN_OP_SUB;
4530  }
4531 #line 4532 "hlsl.tab.c" /* yacc.c:1646 */
4532  break;
4533 
4534  case 166:
4535 #line 2439 "hlsl.y" /* yacc.c:1646 */
4536  {
4537  (yyval.assign_op) = ASSIGN_OP_MUL;
4538  }
4539 #line 4540 "hlsl.tab.c" /* yacc.c:1646 */
4540  break;
4541 
4542  case 167:
4543 #line 2443 "hlsl.y" /* yacc.c:1646 */
4544  {
4545  (yyval.assign_op) = ASSIGN_OP_DIV;
4546  }
4547 #line 4548 "hlsl.tab.c" /* yacc.c:1646 */
4548  break;
4549 
4550  case 168:
4551 #line 2447 "hlsl.y" /* yacc.c:1646 */
4552  {
4553  (yyval.assign_op) = ASSIGN_OP_MOD;
4554  }
4555 #line 4556 "hlsl.tab.c" /* yacc.c:1646 */
4556  break;
4557 
4558  case 169:
4559 #line 2451 "hlsl.y" /* yacc.c:1646 */
4560  {
4561  (yyval.assign_op) = ASSIGN_OP_LSHIFT;
4562  }
4563 #line 4564 "hlsl.tab.c" /* yacc.c:1646 */
4564  break;
4565 
4566  case 170:
4567 #line 2455 "hlsl.y" /* yacc.c:1646 */
4568  {
4569  (yyval.assign_op) = ASSIGN_OP_RSHIFT;
4570  }
4571 #line 4572 "hlsl.tab.c" /* yacc.c:1646 */
4572  break;
4573 
4574  case 171:
4575 #line 2459 "hlsl.y" /* yacc.c:1646 */
4576  {
4577  (yyval.assign_op) = ASSIGN_OP_AND;
4578  }
4579 #line 4580 "hlsl.tab.c" /* yacc.c:1646 */
4580  break;
4581 
4582  case 172:
4583 #line 2463 "hlsl.y" /* yacc.c:1646 */
4584  {
4585  (yyval.assign_op) = ASSIGN_OP_OR;
4586  }
4587 #line 4588 "hlsl.tab.c" /* yacc.c:1646 */
4588  break;
4589 
4590  case 173:
4591 #line 2467 "hlsl.y" /* yacc.c:1646 */
4592  {
4593  (yyval.assign_op) = ASSIGN_OP_XOR;
4594  }
4595 #line 4596 "hlsl.tab.c" /* yacc.c:1646 */
4596  break;
4597 
4598  case 174:
4599 #line 2472 "hlsl.y" /* yacc.c:1646 */
4600  {
4601  (yyval.instr) = (yyvsp[0].instr);
4602  }
4603 #line 4604 "hlsl.tab.c" /* yacc.c:1646 */
4604  break;
4605 
4606  case 175:
4607 #line 2476 "hlsl.y" /* yacc.c:1646 */
4608  {
4609  FIXME("Comma expression\n");
4610  }
4611 #line 4612 "hlsl.tab.c" /* yacc.c:1646 */
4612  break;
4613 
4614 
4615 #line 4616 "hlsl.tab.c" /* yacc.c:1646 */
4616  default: break;
4617  }
4618  /* User semantic actions sometimes alter yychar, and that requires
4619  that yytoken be updated with the new translation. We take the
4620  approach of translating immediately before every use of yytoken.
4621  One alternative is translating here after every semantic action,
4622  but that translation would be missed if the semantic action invokes
4623  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
4624  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
4625  incorrect destructor might then be invoked immediately. In the
4626  case of YYERROR or YYBACKUP, subsequent parser actions might lead
4627  to an incorrect destructor call or verbose syntax error message
4628  before the lookahead is translated. */
4629  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
4630 
4631  YYPOPSTACK (yylen);
4632  yylen = 0;
4633  YY_STACK_PRINT (yyss, yyssp);
4634 
4635  *++yyvsp = yyval;
4636  *++yylsp = yyloc;
4637 
4638  /* Now 'shift' the result of the reduction. Determine what state
4639  that goes to, based on the state we popped back to and the rule
4640  number reduced by. */
4641 
4642  yyn = yyr1[yyn];
4643 
4644  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
4645  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4646  yystate = yytable[yystate];
4647  else
4648  yystate = yydefgoto[yyn - YYNTOKENS];
4649 
4650  goto yynewstate;
4651 
4652 
4653 /*--------------------------------------.
4654 | yyerrlab -- here on detecting error. |
4655 `--------------------------------------*/
4656 yyerrlab:
4657  /* Make sure we have latest lookahead translation. See comments at
4658  user semantic actions for why this is necessary. */
4659  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
4660 
4661  /* If not already recovering from an error, report this error. */
4662  if (!yyerrstatus)
4663  {
4664  ++yynerrs;
4665 #if ! YYERROR_VERBOSE
4666  yyerror (YY_("syntax error"));
4667 #else
4668 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
4669  yyssp, yytoken)
4670  {
4671  char const *yymsgp = YY_("syntax error");
4672  int yysyntax_error_status;
4673  yysyntax_error_status = YYSYNTAX_ERROR;
4674  if (yysyntax_error_status == 0)
4675  yymsgp = yymsg;
4676  else if (yysyntax_error_status == 1)
4677  {
4678  if (yymsg != yymsgbuf)
4679  YYSTACK_FREE (yymsg);
4680  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
4681  if (!yymsg)
4682  {
4683  yymsg = yymsgbuf;
4684  yymsg_alloc = sizeof yymsgbuf;
4685  yysyntax_error_status = 2;
4686  }
4687  else
4688  {
4689  yysyntax_error_status = YYSYNTAX_ERROR;
4690  yymsgp = yymsg;
4691  }
4692  }
4693  yyerror (yymsgp);
4694  if (yysyntax_error_status == 2)
4695  goto yyexhaustedlab;
4696  }
4697 # undef YYSYNTAX_ERROR
4698 #endif
4699  }
4700 
4701  yyerror_range[1] = yylloc;
4702 
4703  if (yyerrstatus == 3)
4704  {
4705  /* If just tried and failed to reuse lookahead token after an
4706  error, discard it. */
4707 
4708  if (yychar <= YYEOF)
4709  {
4710  /* Return failure if at end of input. */
4711  if (yychar == YYEOF)
4712  YYABORT;
4713  }
4714  else
4715  {
4716  yydestruct ("Error: discarding",
4717  yytoken, &yylval, &yylloc);
4718  yychar = YYEMPTY;
4719  }
4720  }
4721 
4722  /* Else will try to reuse lookahead token after shifting the error
4723  token. */
4724  goto yyerrlab1;
4725 
4726 
4727 /*---------------------------------------------------.
4728 | yyerrorlab -- error raised explicitly by YYERROR. |
4729 `---------------------------------------------------*/
4730 yyerrorlab:
4731 
4732  /* Pacify compilers like GCC when the user code never invokes
4733  YYERROR and the label yyerrorlab therefore never appears in user
4734  code. */
4735  if (/*CONSTCOND*/ 0)
4736  goto yyerrorlab;
4737 
4738  yyerror_range[1] = yylsp[1-yylen];
4739  /* Do not reclaim the symbols of the rule whose action triggered
4740  this YYERROR. */
4741  YYPOPSTACK (yylen);
4742  yylen = 0;
4743  YY_STACK_PRINT (yyss, yyssp);
4744  yystate = *yyssp;
4745  goto yyerrlab1;
4746 
4747 
4748 /*-------------------------------------------------------------.
4749 | yyerrlab1 -- common code for both syntax error and YYERROR. |
4750 `-------------------------------------------------------------*/
4751 yyerrlab1:
4752  yyerrstatus = 3; /* Each real token shifted decrements this. */
4753 
4754  for (;;)
4755  {
4756  yyn = yypact[yystate];
4757  if (!yypact_value_is_default (yyn))
4758  {
4759  yyn += YYTERROR;
4760  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
4761  {
4762  yyn = yytable[yyn];
4763  if (0 < yyn)
4764  break;
4765  }
4766  }
4767 
4768  /* Pop the current state because it cannot handle the error token. */
4769  if (yyssp == yyss)
4770  YYABORT;
4771 
4772  yyerror_range[1] = *yylsp;
4773  yydestruct ("Error: popping",
4774  yystos[yystate], yyvsp, yylsp);
4775  YYPOPSTACK (1);
4776  yystate = *yyssp;
4777  YY_STACK_PRINT (yyss, yyssp);
4778  }
4779 
4781  *++yyvsp = yylval;
4783 
4784  yyerror_range[2] = yylloc;
4785  /* Using YYLLOC is tempting, but would change the location of
4786  the lookahead. YYLOC is available though. */
4787  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
4788  *++yylsp = yyloc;
4789 
4790  /* Shift the error token. */
4791  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
4792 
4793  yystate = yyn;
4794  goto yynewstate;
4795 
4796 
4797 /*-------------------------------------.
4798 | yyacceptlab -- YYACCEPT comes here. |
4799 `-------------------------------------*/
4800 yyacceptlab:
4801  yyresult = 0;
4802  goto yyreturn;
4803 
4804 /*-----------------------------------.
4805 | yyabortlab -- YYABORT comes here. |
4806 `-----------------------------------*/
4807 yyabortlab:
4808  yyresult = 1;
4809  goto yyreturn;
4810 
4811 #if !defined yyoverflow || YYERROR_VERBOSE
4812 /*-------------------------------------------------.
4813 | yyexhaustedlab -- memory exhaustion comes here. |
4814 `-------------------------------------------------*/
4815 yyexhaustedlab:
4816  yyerror (YY_("memory exhausted"));
4817  yyresult = 2;
4818  /* Fall through. */
4819 #endif
4820 
4821 yyreturn:
4822  if (yychar != YYEMPTY)
4823  {
4824  /* Make sure we have latest lookahead translation. See comments at
4825  user semantic actions for why this is necessary. */
4826  yytoken = YYTRANSLATE (yychar);
4827  yydestruct ("Cleanup: discarding lookahead",
4828  yytoken, &yylval, &yylloc);
4829  }
4830  /* Do not reclaim the symbols of the rule whose action triggered
4831  this YYABORT or YYACCEPT. */
4832  YYPOPSTACK (yylen);
4833  YY_STACK_PRINT (yyss, yyssp);
4834  while (yyssp != yyss)
4835  {
4836  yydestruct ("Cleanup: popping",
4837  yystos[*yyssp], yyvsp, yylsp);
4838  YYPOPSTACK (1);
4839  }
4840 #ifndef yyoverflow
4841  if (yyss != yyssa)
4842  YYSTACK_FREE (yyss);
4843 #endif
4844 #if YYERROR_VERBOSE
4845  if (yymsg != yymsgbuf)
4846  YYSTACK_FREE (yymsg);
4847 #endif
4848  return yyresult;
4849 }
4850 #line 2480 "hlsl.y" /* yacc.c:1906 */
4851 
4852 
4853 static void set_location(struct source_location *loc, const struct YYLTYPE *l)
4854 {
4855  loc->file = hlsl_ctx.source_file;
4856  loc->line = l->first_line;
4857  loc->col = l->first_column;
4858 }
4859 
4860 static DWORD add_modifier(DWORD modifiers, DWORD mod, const struct YYLTYPE *loc)
4861 {
4862  if (modifiers & mod)
4863  {
4865  "modifier '%s' already specified", debug_modifiers(mod));
4866  return modifiers;
4867  }
4870  {
4872  "more than one matrix majority keyword");
4873  return modifiers;
4874  }
4875  return modifiers | mod;
4876 }
4877 
4878 static void dump_function_decl(struct wine_rb_entry *entry, void *context)
4879 {
4881  if (func->body)
4883 }
4884 
4885 static void dump_function(struct wine_rb_entry *entry, void *context)
4886 {
4889 }
4890 
4892  const char *entrypoint, char **messages)
4893 {
4894  struct hlsl_scope *scope, *next_scope;
4895  struct hlsl_type *hlsl_type, *next_type;
4896  struct hlsl_ir_var *var, *next_var;
4897  unsigned int i;
4898 
4899  hlsl_ctx.status = PARSE_SUCCESS;
4900  hlsl_ctx.messages.size = hlsl_ctx.messages.capacity = 0;
4901  hlsl_ctx.line_no = hlsl_ctx.column = 1;
4902  hlsl_ctx.source_file = d3dcompiler_strdup("");
4903  hlsl_ctx.source_files = d3dcompiler_alloc(sizeof(*hlsl_ctx.source_files));
4904  if (hlsl_ctx.source_files)
4905  hlsl_ctx.source_files[0] = hlsl_ctx.source_file;
4906  hlsl_ctx.source_files_count = 1;
4907  hlsl_ctx.cur_scope = NULL;
4908  hlsl_ctx.matrix_majority = HLSL_COLUMN_MAJOR;
4909  list_init(&hlsl_ctx.scopes);
4910  list_init(&hlsl_ctx.types);
4911  init_functions_tree(&hlsl_ctx.functions);
4912 
4913  push_scope(&hlsl_ctx);
4914  hlsl_ctx.globals = hlsl_ctx.cur_scope;
4916 
4917  hlsl_parse();
4918 
4919  if (TRACE_ON(hlsl_parser))
4920  {
4921  TRACE("IR dump.\n");
4923  }
4924 
4925  TRACE("Compilation status = %d\n", hlsl_ctx.status);
4926  if (messages)
4927  {
4928  if (hlsl_ctx.messages.size)
4929  *messages = hlsl_ctx.messages.string;
4930  else
4931  *messages = NULL;
4932  }
4933  else
4934  {
4935  if (hlsl_ctx.messages.capacity)
4936  d3dcompiler_free(hlsl_ctx.messages.string);
4937  }
4938 
4939  for (i = 0; i < hlsl_ctx.source_files_count; ++i)
4940  d3dcompiler_free((void *)hlsl_ctx.source_files[i]);
4941  d3dcompiler_free(hlsl_ctx.source_files);
4942 
4943  TRACE("Freeing functions IR.\n");
4945 
4946  TRACE("Freeing variables.\n");
4947  LIST_FOR_EACH_ENTRY_SAFE(scope, next_scope, &hlsl_ctx.scopes, struct hlsl_scope, entry)
4948  {
4949  LIST_FOR_EACH_ENTRY_SAFE(var, next_var, &scope->vars, struct hlsl_ir_var, scope_entry)
4950  {
4951  free_declaration(var);
4952  }
4953  wine_rb_destroy(&scope->types, NULL, NULL);
4954  d3dcompiler_free(scope);
4955  }
4956 
4957  TRACE("Freeing types.\n");
4958  LIST_FOR_EACH_ENTRY_SAFE(hlsl_type, next_type, &hlsl_ctx.types, struct hlsl_type, entry)
4959  {
4961  }
4962 
4963  return NULL;
4964 }
const char * semantic
#define yynerrs
Definition: hlsl.tab.c:67
int first_column
Definition: hlsl.tab.c:1135
GLenum func
Definition: glext.h:6028
char * name
Definition: hlsl.tab.c:1109
static const WCHAR invalid[]
Definition: assoc.c:39
#define vsnprintf
Definition: tif_win32.c:406
static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
Definition: hlsl.tab.c:175
static int yysyntax_error(YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken)
Definition: hlsl.tab.c:2256
void free_hlsl_type(struct hlsl_type *type) DECLSPEC_HIDDEN
Definition: utils.c:2278
bwritershader_param_register_type
GLint level
Definition: gl.h:1546
struct hlsl_ir_node node
void free(void *)
Definition: cabinet.c:147
static unsigned int components_count_expr_list(struct list *list)
Definition: hlsl.tab.c:449
signed char yytype_int8
Definition: hlsl.tab.c:1167
struct parse_variable_def * variable_def
Definition: hlsl.tab.c:1116
short int yytype_int16
Definition: hlsl.tab.c:1179
struct reg_reservation * reg_reservation
Definition: hlsl.tab.c:1120
#define TRUE
Definition: types.h:120
#define yychar
Definition: hlsl.tab.c:70
#define YYSTACK_ALLOC
Definition: hlsl.tab.c:1283
static void * d3dcompiler_realloc(void *ptr, SIZE_T size)
static void hlsl_error(const char *s)
Definition: hlsl.tab.c:153
#define yyparse
Definition: hlsl.tab.c:63
static void check_invalid_matrix_modifiers(DWORD modifiers, struct source_location *loc)
Definition: hlsl.tab.c:166
struct bwriter_shader * parse_hlsl(enum shader_type type, DWORD major, DWORD minor, const char *entrypoint, char **messages)
Definition: hlsl.tab.c:4891
LOCAL int expr(arg_t *ap, int *altp)
Definition: match.c:512
const struct reg_reservation * reg_reservation
static struct reg_reservation * parse_reg_reservation(const char *reg_string)
Definition: hlsl.tab.c:892
struct hlsl_ir_expr * hlsl_gt(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location *loc) DECLSPEC_HIDDEN
Definition: utils.c:1447
struct hlsl_ir_expr * new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands, struct source_location *loc) DECLSPEC_HIDDEN
Definition: utils.c:1298