glsl: Change is_precision_statement to default_precision != none.
[mesa.git] / src / glsl / ast.h
1 /* -*- c++ -*- */
2 /*
3 * Copyright © 2009 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #pragma once
26 #ifndef AST_H
27 #define AST_H
28
29 #include "list.h"
30 #include "glsl_parser_extras.h"
31
32 struct _mesa_glsl_parse_state;
33
34 struct YYLTYPE;
35
36 /**
37 * \defgroup AST Abstract syntax tree node definitions
38 *
39 * An abstract syntax tree is generated by the parser. This is a fairly
40 * direct representation of the gramma derivation for the source program.
41 * No symantic checking is done during the generation of the AST. Only
42 * syntactic checking is done. Symantic checking is performed by a later
43 * stage that converts the AST to a more generic intermediate representation.
44 *
45 *@{
46 */
47 /**
48 * Base class of all abstract syntax tree nodes
49 */
50 class ast_node {
51 public:
52 /* Callers of this ralloc-based new need not call delete. It's
53 * easier to just ralloc_free 'ctx' (or any of its ancestors). */
54 static void* operator new(size_t size, void *ctx)
55 {
56 void *node;
57
58 node = rzalloc_size(ctx, size);
59 assert(node != NULL);
60
61 return node;
62 }
63
64 /* If the user *does* call delete, that's OK, we will just
65 * ralloc_free in that case. */
66 static void operator delete(void *table)
67 {
68 ralloc_free(table);
69 }
70
71 /**
72 * Print an AST node in something approximating the original GLSL code
73 */
74 virtual void print(void) const;
75
76 /**
77 * Convert the AST node to the high-level intermediate representation
78 */
79 virtual ir_rvalue *hir(exec_list *instructions,
80 struct _mesa_glsl_parse_state *state);
81
82 /**
83 * Retrieve the source location of an AST node
84 *
85 * This function is primarily used to get the source position of an AST node
86 * into a form that can be passed to \c _mesa_glsl_error.
87 *
88 * \sa _mesa_glsl_error, ast_node::set_location
89 */
90 struct YYLTYPE get_location(void) const
91 {
92 struct YYLTYPE locp;
93
94 locp.source = this->location.source;
95 locp.first_line = this->location.line;
96 locp.first_column = this->location.column;
97 locp.last_line = locp.first_line;
98 locp.last_column = locp.first_column;
99
100 return locp;
101 }
102
103 /**
104 * Set the source location of an AST node from a parser location
105 *
106 * \sa ast_node::get_location
107 */
108 void set_location(const struct YYLTYPE &locp)
109 {
110 this->location.source = locp.source;
111 this->location.line = locp.first_line;
112 this->location.column = locp.first_column;
113 }
114
115 /**
116 * Source location of the AST node.
117 */
118 struct {
119 unsigned source; /**< GLSL source number. */
120 unsigned line; /**< Line number within the source string. */
121 unsigned column; /**< Column in the line. */
122 } location;
123
124 exec_node link;
125
126 protected:
127 /**
128 * The only constructor is protected so that only derived class objects can
129 * be created.
130 */
131 ast_node(void);
132 };
133
134
135 /**
136 * Operators for AST expression nodes.
137 */
138 enum ast_operators {
139 ast_assign,
140 ast_plus, /**< Unary + operator. */
141 ast_neg,
142 ast_add,
143 ast_sub,
144 ast_mul,
145 ast_div,
146 ast_mod,
147 ast_lshift,
148 ast_rshift,
149 ast_less,
150 ast_greater,
151 ast_lequal,
152 ast_gequal,
153 ast_equal,
154 ast_nequal,
155 ast_bit_and,
156 ast_bit_xor,
157 ast_bit_or,
158 ast_bit_not,
159 ast_logic_and,
160 ast_logic_xor,
161 ast_logic_or,
162 ast_logic_not,
163
164 ast_mul_assign,
165 ast_div_assign,
166 ast_mod_assign,
167 ast_add_assign,
168 ast_sub_assign,
169 ast_ls_assign,
170 ast_rs_assign,
171 ast_and_assign,
172 ast_xor_assign,
173 ast_or_assign,
174
175 ast_conditional,
176
177 ast_pre_inc,
178 ast_pre_dec,
179 ast_post_inc,
180 ast_post_dec,
181 ast_field_selection,
182 ast_array_index,
183
184 ast_function_call,
185
186 ast_identifier,
187 ast_int_constant,
188 ast_uint_constant,
189 ast_float_constant,
190 ast_bool_constant,
191
192 ast_sequence,
193 ast_aggregate
194 };
195
196 /**
197 * Representation of any sort of expression.
198 */
199 class ast_expression : public ast_node {
200 public:
201 ast_expression(int oper, ast_expression *,
202 ast_expression *, ast_expression *);
203
204 ast_expression(const char *identifier) :
205 oper(ast_identifier)
206 {
207 subexpressions[0] = NULL;
208 subexpressions[1] = NULL;
209 subexpressions[2] = NULL;
210 primary_expression.identifier = identifier;
211 this->non_lvalue_description = NULL;
212 }
213
214 static const char *operator_string(enum ast_operators op);
215
216 virtual ir_rvalue *hir(exec_list *instructions,
217 struct _mesa_glsl_parse_state *state);
218
219 virtual void print(void) const;
220
221 enum ast_operators oper;
222
223 ast_expression *subexpressions[3];
224
225 union {
226 const char *identifier;
227 int int_constant;
228 float float_constant;
229 unsigned uint_constant;
230 int bool_constant;
231 } primary_expression;
232
233
234 /**
235 * List of expressions for an \c ast_sequence or parameters for an
236 * \c ast_function_call
237 */
238 exec_list expressions;
239
240 /**
241 * For things that can't be l-values, this describes what it is.
242 *
243 * This text is used by the code that generates IR for assignments to
244 * detect and emit useful messages for assignments to some things that
245 * can't be l-values. For example, pre- or post-incerement expressions.
246 *
247 * \note
248 * This pointer may be \c NULL.
249 */
250 const char *non_lvalue_description;
251 };
252
253 class ast_expression_bin : public ast_expression {
254 public:
255 ast_expression_bin(int oper, ast_expression *, ast_expression *);
256
257 virtual void print(void) const;
258 };
259
260 /**
261 * Subclass of expressions for function calls
262 */
263 class ast_function_expression : public ast_expression {
264 public:
265 ast_function_expression(ast_expression *callee)
266 : ast_expression(ast_function_call, callee,
267 NULL, NULL),
268 cons(false)
269 {
270 /* empty */
271 }
272
273 ast_function_expression(class ast_type_specifier *type)
274 : ast_expression(ast_function_call, (ast_expression *) type,
275 NULL, NULL),
276 cons(true)
277 {
278 /* empty */
279 }
280
281 bool is_constructor() const
282 {
283 return cons;
284 }
285
286 virtual ir_rvalue *hir(exec_list *instructions,
287 struct _mesa_glsl_parse_state *state);
288
289 private:
290 /**
291 * Is this function call actually a constructor?
292 */
293 bool cons;
294 };
295
296 /**
297 * C-style aggregate initialization class
298 *
299 * Represents C-style initializers of vectors, matrices, arrays, and
300 * structures. E.g., vec3 pos = {1.0, 0.0, -1.0} is equivalent to
301 * vec3 pos = vec3(1.0, 0.0, -1.0).
302 *
303 * Specified in GLSL 4.20 and GL_ARB_shading_language_420pack.
304 *
305 * \sa _mesa_ast_set_aggregate_type
306 */
307 class ast_aggregate_initializer : public ast_expression {
308 public:
309 ast_aggregate_initializer()
310 : ast_expression(ast_aggregate, NULL, NULL, NULL),
311 constructor_type(NULL)
312 {
313 /* empty */
314 }
315
316 ast_type_specifier *constructor_type;
317 virtual ir_rvalue *hir(exec_list *instructions,
318 struct _mesa_glsl_parse_state *state);
319 };
320
321 /**
322 * Number of possible operators for an ast_expression
323 *
324 * This is done as a define instead of as an additional value in the enum so
325 * that the compiler won't generate spurious messages like "warning:
326 * enumeration value ‘ast_num_operators’ not handled in switch"
327 */
328 #define AST_NUM_OPERATORS (ast_sequence + 1)
329
330
331 class ast_compound_statement : public ast_node {
332 public:
333 ast_compound_statement(int new_scope, ast_node *statements);
334 virtual void print(void) const;
335
336 virtual ir_rvalue *hir(exec_list *instructions,
337 struct _mesa_glsl_parse_state *state);
338
339 int new_scope;
340 exec_list statements;
341 };
342
343 class ast_declaration : public ast_node {
344 public:
345 ast_declaration(const char *identifier, bool is_array, ast_expression *array_size,
346 ast_expression *initializer);
347 virtual void print(void) const;
348
349 const char *identifier;
350
351 bool is_array;
352 ast_expression *array_size;
353
354 ast_expression *initializer;
355 };
356
357
358 enum {
359 ast_precision_none = 0, /**< Absence of precision qualifier. */
360 ast_precision_high,
361 ast_precision_medium,
362 ast_precision_low
363 };
364
365 struct ast_type_qualifier {
366 /* Callers of this ralloc-based new need not call delete. It's
367 * easier to just ralloc_free 'ctx' (or any of its ancestors). */
368 static void* operator new(size_t size, void *ctx)
369 {
370 void *node;
371
372 node = rzalloc_size(ctx, size);
373 assert(node != NULL);
374
375 return node;
376 }
377
378 /* If the user *does* call delete, that's OK, we will just
379 * ralloc_free in that case. */
380 static void operator delete(void *table)
381 {
382 ralloc_free(table);
383 }
384
385 union {
386 struct {
387 unsigned invariant:1;
388 unsigned constant:1;
389 unsigned attribute:1;
390 unsigned varying:1;
391 unsigned in:1;
392 unsigned out:1;
393 unsigned centroid:1;
394 unsigned uniform:1;
395 unsigned smooth:1;
396 unsigned flat:1;
397 unsigned noperspective:1;
398
399 /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */
400 /*@{*/
401 unsigned origin_upper_left:1;
402 unsigned pixel_center_integer:1;
403 /*@}*/
404
405 /**
406 * Flag set if GL_ARB_explicit_attrib_location "location" layout
407 * qualifier is used.
408 */
409 unsigned explicit_location:1;
410 /**
411 * Flag set if GL_ARB_explicit_attrib_location "index" layout
412 * qualifier is used.
413 */
414 unsigned explicit_index:1;
415
416 /** \name Layout qualifiers for GL_AMD_conservative_depth */
417 /** \{ */
418 unsigned depth_any:1;
419 unsigned depth_greater:1;
420 unsigned depth_less:1;
421 unsigned depth_unchanged:1;
422 /** \} */
423
424 /** \name Layout qualifiers for GL_ARB_uniform_buffer_object */
425 /** \{ */
426 unsigned std140:1;
427 unsigned shared:1;
428 unsigned packed:1;
429 unsigned column_major:1;
430 unsigned row_major:1;
431 /** \} */
432 }
433 /** \brief Set of flags, accessed by name. */
434 q;
435
436 /** \brief Set of flags, accessed as a bitmask. */
437 unsigned i;
438 } flags;
439
440 /**
441 * Location specified via GL_ARB_explicit_attrib_location layout
442 *
443 * \note
444 * This field is only valid if \c explicit_location is set.
445 */
446 int location;
447 /**
448 * Index specified via GL_ARB_explicit_attrib_location layout
449 *
450 * \note
451 * This field is only valid if \c explicit_index is set.
452 */
453 int index;
454
455 /**
456 * Return true if and only if an interpolation qualifier is present.
457 */
458 bool has_interpolation() const;
459
460 /**
461 * Return whether a layout qualifier is present.
462 */
463 bool has_layout() const;
464
465 /**
466 * Return whether a storage qualifier is present.
467 */
468 bool has_storage() const;
469
470 /**
471 * Return whether an auxiliary storage qualifier is present.
472 */
473 bool has_auxiliary_storage() const;
474
475 /**
476 * \brief Return string representation of interpolation qualifier.
477 *
478 * If an interpolation qualifier is present, then return that qualifier's
479 * string representation. Otherwise, return null. For example, if the
480 * noperspective bit is set, then this returns "noperspective".
481 *
482 * If multiple interpolation qualifiers are somehow present, then the
483 * returned string is undefined but not null.
484 */
485 const char *interpolation_string() const;
486
487 bool merge_qualifier(YYLTYPE *loc,
488 _mesa_glsl_parse_state *state,
489 ast_type_qualifier q);
490 };
491
492 class ast_declarator_list;
493
494 class ast_struct_specifier : public ast_node {
495 public:
496 /**
497 * \brief Make a shallow copy of an ast_struct_specifier.
498 *
499 * Use only if the objects are allocated from the same context and will not
500 * be modified. Zeros the inherited ast_node's fields.
501 */
502 ast_struct_specifier(const ast_struct_specifier& that):
503 ast_node(), name(that.name), declarations(that.declarations),
504 is_declaration(that.is_declaration)
505 {
506 /* empty */
507 }
508
509 ast_struct_specifier(const char *identifier,
510 ast_declarator_list *declarator_list);
511 virtual void print(void) const;
512
513 virtual ir_rvalue *hir(exec_list *instructions,
514 struct _mesa_glsl_parse_state *state);
515
516 const char *name;
517 /* List of ast_declarator_list * */
518 exec_list declarations;
519 bool is_declaration;
520 };
521
522
523
524 class ast_type_specifier : public ast_node {
525 public:
526 /**
527 * \brief Make a shallow copy of an ast_type_specifier, specifying array
528 * fields.
529 *
530 * Use only if the objects are allocated from the same context and will not
531 * be modified. Zeros the inherited ast_node's fields.
532 */
533 ast_type_specifier(const ast_type_specifier *that, bool is_array,
534 ast_expression *array_size)
535 : ast_node(), type_name(that->type_name), structure(that->structure),
536 is_array(is_array), array_size(array_size), precision(that->precision),
537 default_precision(that->default_precision)
538 {
539 /* empty */
540 }
541
542 /** Construct a type specifier from a type name */
543 ast_type_specifier(const char *name)
544 : type_name(name), structure(NULL),
545 is_array(false), array_size(NULL), precision(ast_precision_none),
546 default_precision(ast_precision_none)
547 {
548 /* empty */
549 }
550
551 /** Construct a type specifier from a structure definition */
552 ast_type_specifier(ast_struct_specifier *s)
553 : type_name(s->name), structure(s),
554 is_array(false), array_size(NULL), precision(ast_precision_none),
555 default_precision(ast_precision_none)
556 {
557 /* empty */
558 }
559
560 const struct glsl_type *glsl_type(const char **name,
561 struct _mesa_glsl_parse_state *state)
562 const;
563
564 virtual void print(void) const;
565
566 ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
567
568 const char *type_name;
569 ast_struct_specifier *structure;
570
571 bool is_array;
572 ast_expression *array_size;
573
574 unsigned precision:2;
575
576 /** For precision statements, this is the given precision; otherwise none. */
577 unsigned default_precision:2;
578 };
579
580
581 class ast_fully_specified_type : public ast_node {
582 public:
583 virtual void print(void) const;
584 bool has_qualifiers() const;
585
586 ast_type_qualifier qualifier;
587 ast_type_specifier *specifier;
588 };
589
590
591 class ast_declarator_list : public ast_node {
592 public:
593 ast_declarator_list(ast_fully_specified_type *);
594 virtual void print(void) const;
595
596 virtual ir_rvalue *hir(exec_list *instructions,
597 struct _mesa_glsl_parse_state *state);
598
599 ast_fully_specified_type *type;
600 /** List of 'ast_declaration *' */
601 exec_list declarations;
602
603 /**
604 * Special flag for vertex shader "invariant" declarations.
605 *
606 * Vertex shaders can contain "invariant" variable redeclarations that do
607 * not include a type. For example, "invariant gl_Position;". This flag
608 * is used to note these cases when no type is specified.
609 */
610 int invariant;
611
612 /**
613 * Flag indicating that these declarators are in a uniform block,
614 * allowing UBO type qualifiers.
615 */
616 bool ubo_qualifiers_valid;
617 };
618
619
620 class ast_parameter_declarator : public ast_node {
621 public:
622 ast_parameter_declarator() :
623 type(NULL),
624 identifier(NULL),
625 is_array(false),
626 array_size(NULL),
627 formal_parameter(false),
628 is_void(false)
629 {
630 /* empty */
631 }
632
633 virtual void print(void) const;
634
635 virtual ir_rvalue *hir(exec_list *instructions,
636 struct _mesa_glsl_parse_state *state);
637
638 ast_fully_specified_type *type;
639 const char *identifier;
640 bool is_array;
641 ast_expression *array_size;
642
643 static void parameters_to_hir(exec_list *ast_parameters,
644 bool formal, exec_list *ir_parameters,
645 struct _mesa_glsl_parse_state *state);
646
647 private:
648 /** Is this parameter declaration part of a formal parameter list? */
649 bool formal_parameter;
650
651 /**
652 * Is this parameter 'void' type?
653 *
654 * This field is set by \c ::hir.
655 */
656 bool is_void;
657 };
658
659
660 class ast_function : public ast_node {
661 public:
662 ast_function(void);
663
664 virtual void print(void) const;
665
666 virtual ir_rvalue *hir(exec_list *instructions,
667 struct _mesa_glsl_parse_state *state);
668
669 ast_fully_specified_type *return_type;
670 const char *identifier;
671
672 exec_list parameters;
673
674 private:
675 /**
676 * Is this prototype part of the function definition?
677 *
678 * Used by ast_function_definition::hir to process the parameters, etc.
679 * of the function.
680 *
681 * \sa ::hir
682 */
683 bool is_definition;
684
685 /**
686 * Function signature corresponding to this function prototype instance
687 *
688 * Used by ast_function_definition::hir to process the parameters, etc.
689 * of the function.
690 *
691 * \sa ::hir
692 */
693 class ir_function_signature *signature;
694
695 friend class ast_function_definition;
696 };
697
698
699 class ast_expression_statement : public ast_node {
700 public:
701 ast_expression_statement(ast_expression *);
702 virtual void print(void) const;
703
704 virtual ir_rvalue *hir(exec_list *instructions,
705 struct _mesa_glsl_parse_state *state);
706
707 ast_expression *expression;
708 };
709
710
711 class ast_case_label : public ast_node {
712 public:
713 ast_case_label(ast_expression *test_value);
714 virtual void print(void) const;
715
716 virtual ir_rvalue *hir(exec_list *instructions,
717 struct _mesa_glsl_parse_state *state);
718
719 /**
720 * An test value of NULL means 'default'.
721 */
722 ast_expression *test_value;
723 };
724
725
726 class ast_case_label_list : public ast_node {
727 public:
728 ast_case_label_list(void);
729 virtual void print(void) const;
730
731 virtual ir_rvalue *hir(exec_list *instructions,
732 struct _mesa_glsl_parse_state *state);
733
734 /**
735 * A list of case labels.
736 */
737 exec_list labels;
738 };
739
740
741 class ast_case_statement : public ast_node {
742 public:
743 ast_case_statement(ast_case_label_list *labels);
744 virtual void print(void) const;
745
746 virtual ir_rvalue *hir(exec_list *instructions,
747 struct _mesa_glsl_parse_state *state);
748
749 ast_case_label_list *labels;
750
751 /**
752 * A list of statements.
753 */
754 exec_list stmts;
755 };
756
757
758 class ast_case_statement_list : public ast_node {
759 public:
760 ast_case_statement_list(void);
761 virtual void print(void) const;
762
763 virtual ir_rvalue *hir(exec_list *instructions,
764 struct _mesa_glsl_parse_state *state);
765
766 /**
767 * A list of cases.
768 */
769 exec_list cases;
770 };
771
772
773 class ast_switch_body : public ast_node {
774 public:
775 ast_switch_body(ast_case_statement_list *stmts);
776 virtual void print(void) const;
777
778 virtual ir_rvalue *hir(exec_list *instructions,
779 struct _mesa_glsl_parse_state *state);
780
781 ast_case_statement_list *stmts;
782 };
783
784
785 class ast_selection_statement : public ast_node {
786 public:
787 ast_selection_statement(ast_expression *condition,
788 ast_node *then_statement,
789 ast_node *else_statement);
790 virtual void print(void) const;
791
792 virtual ir_rvalue *hir(exec_list *instructions,
793 struct _mesa_glsl_parse_state *state);
794
795 ast_expression *condition;
796 ast_node *then_statement;
797 ast_node *else_statement;
798 };
799
800
801 class ast_switch_statement : public ast_node {
802 public:
803 ast_switch_statement(ast_expression *test_expression,
804 ast_node *body);
805 virtual void print(void) const;
806
807 virtual ir_rvalue *hir(exec_list *instructions,
808 struct _mesa_glsl_parse_state *state);
809
810 ast_expression *test_expression;
811 ast_node *body;
812
813 protected:
814 void test_to_hir(exec_list *, struct _mesa_glsl_parse_state *);
815 };
816
817 class ast_iteration_statement : public ast_node {
818 public:
819 ast_iteration_statement(int mode, ast_node *init, ast_node *condition,
820 ast_expression *rest_expression, ast_node *body);
821
822 virtual void print(void) const;
823
824 virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
825
826 enum ast_iteration_modes {
827 ast_for,
828 ast_while,
829 ast_do_while
830 } mode;
831
832
833 ast_node *init_statement;
834 ast_node *condition;
835 ast_expression *rest_expression;
836
837 ast_node *body;
838
839 private:
840 /**
841 * Generate IR from the condition of a loop
842 *
843 * This is factored out of ::hir because some loops have the condition
844 * test at the top (for and while), and others have it at the end (do-while).
845 */
846 void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *);
847 };
848
849
850 class ast_jump_statement : public ast_node {
851 public:
852 ast_jump_statement(int mode, ast_expression *return_value);
853 virtual void print(void) const;
854
855 virtual ir_rvalue *hir(exec_list *instructions,
856 struct _mesa_glsl_parse_state *state);
857
858 enum ast_jump_modes {
859 ast_continue,
860 ast_break,
861 ast_return,
862 ast_discard
863 } mode;
864
865 ast_expression *opt_return_value;
866 };
867
868
869 class ast_function_definition : public ast_node {
870 public:
871 virtual void print(void) const;
872
873 virtual ir_rvalue *hir(exec_list *instructions,
874 struct _mesa_glsl_parse_state *state);
875
876 ast_function *prototype;
877 ast_compound_statement *body;
878 };
879
880 class ast_interface_block : public ast_node {
881 public:
882 ast_interface_block(ast_type_qualifier layout,
883 const char *instance_name,
884 ast_expression *array_size)
885 : layout(layout), block_name(NULL), instance_name(instance_name),
886 array_size(array_size)
887 {
888 /* empty */
889 }
890
891 virtual ir_rvalue *hir(exec_list *instructions,
892 struct _mesa_glsl_parse_state *state);
893
894 ast_type_qualifier layout;
895 const char *block_name;
896
897 /**
898 * Declared name of the block instance, if specified.
899 *
900 * If the block does not have an instance name, this field will be
901 * \c NULL.
902 */
903 const char *instance_name;
904
905 /** List of ast_declarator_list * */
906 exec_list declarations;
907
908 /**
909 * Declared array size of the block instance
910 *
911 * If the block is not declared as an array, this field will be \c NULL.
912 *
913 * \note
914 * A block can only be an array if it also has an instance name. If this
915 * field is not \c NULL, ::instance_name must also not be \c NULL.
916 */
917 ast_expression *array_size;
918 };
919 /*@}*/
920
921 extern void
922 _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state);
923
924 extern ir_rvalue *
925 _mesa_ast_field_selection_to_hir(const ast_expression *expr,
926 exec_list *instructions,
927 struct _mesa_glsl_parse_state *state);
928
929 extern ir_rvalue *
930 _mesa_ast_array_index_to_hir(void *mem_ctx,
931 struct _mesa_glsl_parse_state *state,
932 ir_rvalue *array, ir_rvalue *idx,
933 YYLTYPE &loc, YYLTYPE &idx_loc);
934
935 extern void
936 _mesa_ast_set_aggregate_type(const ast_type_specifier *type,
937 ast_expression *expr,
938 _mesa_glsl_parse_state *state);
939
940 void
941 emit_function(_mesa_glsl_parse_state *state, ir_function *f);
942
943 extern void
944 check_builtin_array_max_size(const char *name, unsigned size,
945 YYLTYPE loc, struct _mesa_glsl_parse_state *state);
946
947 #endif /* AST_H */