Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1901 | serge | 1 | /* |
2 | * Copyright © 2010 Intel Corporation |
||
3 | * |
||
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
5 | * copy of this software and associated documentation files (the "Software"), |
||
6 | * to deal in the Software without restriction, including without limitation |
||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
8 | * and/or sell copies of the Software, and to permit persons to whom the |
||
9 | * Software is furnished to do so, subject to the following conditions: |
||
10 | * |
||
11 | * The above copyright notice and this permission notice (including the next |
||
12 | * paragraph) shall be included in all copies or substantial portions of the |
||
13 | * Software. |
||
14 | * |
||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
21 | * DEALINGS IN THE SOFTWARE. |
||
22 | */ |
||
23 | |||
24 | #include |
||
25 | #include "ast.h" |
||
26 | extern "C" { |
||
27 | #include "program/symbol_table.h" |
||
28 | } |
||
29 | |||
30 | void |
||
31 | ast_type_specifier::print(void) const |
||
32 | { |
||
33 | if (type_specifier == ast_struct) { |
||
34 | structure->print(); |
||
35 | } else { |
||
36 | printf("%s ", type_name); |
||
37 | } |
||
38 | |||
39 | if (is_array) { |
||
40 | printf("[ "); |
||
41 | |||
42 | if (array_size) { |
||
43 | array_size->print(); |
||
44 | } |
||
45 | |||
46 | printf("] "); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | ast_type_specifier::ast_type_specifier(int specifier) |
||
51 | : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL), |
||
52 | is_array(false), array_size(NULL), precision(ast_precision_none), |
||
53 | is_precision_statement(false) |
||
54 | { |
||
55 | static const char *const names[] = { |
||
56 | "void", |
||
57 | "float", |
||
58 | "int", |
||
59 | "uint", |
||
60 | "bool", |
||
61 | "vec2", |
||
62 | "vec3", |
||
63 | "vec4", |
||
64 | "bvec2", |
||
65 | "bvec3", |
||
66 | "bvec4", |
||
67 | "ivec2", |
||
68 | "ivec3", |
||
69 | "ivec4", |
||
70 | "uvec2", |
||
71 | "uvec3", |
||
72 | "uvec4", |
||
73 | "mat2", |
||
74 | "mat2x3", |
||
75 | "mat2x4", |
||
76 | "mat3x2", |
||
77 | "mat3", |
||
78 | "mat3x4", |
||
79 | "mat4x2", |
||
80 | "mat4x3", |
||
81 | "mat4", |
||
82 | "sampler1D", |
||
83 | "sampler2D", |
||
84 | "sampler2DRect", |
||
85 | "sampler3D", |
||
86 | "samplerCube", |
||
87 | "sampler1DShadow", |
||
88 | "sampler2DShadow", |
||
89 | "sampler2DRectShadow", |
||
90 | "samplerCubeShadow", |
||
91 | "sampler1DArray", |
||
92 | "sampler2DArray", |
||
93 | "sampler1DArrayShadow", |
||
94 | "sampler2DArrayShadow", |
||
95 | "isampler1D", |
||
96 | "isampler2D", |
||
97 | "isampler3D", |
||
98 | "isamplerCube", |
||
99 | "isampler1DArray", |
||
100 | "isampler2DArray", |
||
101 | "usampler1D", |
||
102 | "usampler2D", |
||
103 | "usampler3D", |
||
104 | "usamplerCube", |
||
105 | "usampler1DArray", |
||
106 | "usampler2DArray", |
||
107 | |||
108 | NULL, /* ast_struct */ |
||
109 | NULL /* ast_type_name */ |
||
110 | }; |
||
111 | |||
112 | type_name = names[specifier]; |
||
113 | } |
||
114 | |||
115 | bool |
||
116 | ast_fully_specified_type::has_qualifiers() const |
||
117 | { |
||
118 | return this->qualifier.flags.i != 0; |
||
119 | } |