summaryrefslogtreecommitdiff
path: root/ast_type.cpp
blob: d2e047e2c43940b8c0f576da410747d7e2521238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * Copyright © 2010 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include <cstdio>
#include "ast.h"
#include "symbol_table.h"

void
ast_type_specifier::print(void) const
{
   switch (type_specifier) {
   case ast_void: printf("void "); break;
   case ast_float: printf("float "); break;
   case ast_int: printf("int "); break;
   case ast_uint: printf("uint "); break;
   case ast_bool: printf("bool "); break;
   case ast_vec2: printf("vec2 "); break;
   case ast_vec3: printf("vec3 "); break;
   case ast_vec4: printf("vec4 "); break;
   case ast_bvec2: printf("bvec2 "); break;
   case ast_bvec3: printf("bvec3 "); break;
   case ast_bvec4: printf("bvec4 "); break;
   case ast_ivec2: printf("ivec2 "); break;
   case ast_ivec3: printf("ivec3 "); break;
   case ast_ivec4: printf("ivec4 "); break;
   case ast_uvec2: printf("uvec2 "); break;
   case ast_uvec3: printf("uvec3 "); break;
   case ast_uvec4: printf("uvec4 "); break;
   case ast_mat2: printf("mat2 "); break;
   case ast_mat2x3: printf("mat2x3 "); break;
   case ast_mat2x4: printf("mat2x4 "); break;
   case ast_mat3x2: printf("mat3x2 "); break;
   case ast_mat3: printf("mat3 "); break;
   case ast_mat3x4: printf("mat3x4 "); break;
   case ast_mat4x2: printf("mat4x2 "); break;
   case ast_mat4x3: printf("mat4x3 "); break;
   case ast_mat4: printf("mat4 "); break;
   case ast_sampler1d: printf("sampler1d "); break;
   case ast_sampler2d: printf("sampler2d "); break;
   case ast_sampler3d: printf("sampler3d "); break;
   case ast_samplercube: printf("samplercube "); break;
   case ast_sampler1dshadow: printf("sampler1dshadow "); break;
   case ast_sampler2dshadow: printf("sampler2dshadow "); break;
   case ast_samplercubeshadow: printf("samplercubeshadow "); break;
   case ast_sampler1darray: printf("sampler1darray "); break;
   case ast_sampler2darray: printf("sampler2darray "); break;
   case ast_sampler1darrayshadow: printf("sampler1darrayshadow "); break;
   case ast_sampler2darrayshadow: printf("sampler2darrayshadow "); break;
   case ast_isampler1d: printf("isampler1d "); break;
   case ast_isampler2d: printf("isampler2d "); break;
   case ast_isampler3d: printf("isampler3d "); break;
   case ast_isamplercube: printf("isamplercube "); break;
   case ast_isampler1darray: printf("isampler1darray "); break;
   case ast_isampler2darray: printf("isampler2darray "); break;
   case ast_usampler1d: printf("usampler1d "); break;
   case ast_usampler2d: printf("usampler2d "); break;
   case ast_usampler3d: printf("usampler3d "); break;
   case ast_usamplercube: printf("usamplercube "); break;
   case ast_usampler1darray: printf("usampler1darray "); break;
   case ast_usampler2darray: printf("usampler2darray "); break;

   case ast_struct:
      structure->print();
      break;

   case ast_type_name: printf("%s ", type_name); break;
   }

   if (is_array) {
      printf("[ ");

      if (array_size) {
	 array_size->print();
      }

      printf("] ");
   }
}

ast_type_specifier::ast_type_specifier(int specifier)
{
   type_specifier = ast_types(specifier);
}