From bbddcb3092dbb80081d9d4d183cd7b6f3804b1d8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 15 Mar 2010 14:09:23 -0700 Subject: [PATCH] Factor ast_type_specifier code out to ast_type.cpp --- Makefile.am | 2 +- ast_type.cpp | 103 +++++++++++++++++++++++++++++++++++++++++ glsl_parser_extras.cpp | 77 ------------------------------ 3 files changed, 104 insertions(+), 78 deletions(-) create mode 100644 ast_type.cpp diff --git a/Makefile.am b/Makefile.am index b2c49b018bb..0865977329d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,7 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = glsl glsl_SOURCES = symbol_table.c hash_table.c glsl_types.cpp \ glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \ - ast_expr.cpp ast_to_hir.cpp ast_function.cpp \ + ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \ ir.cpp hir_field_selection.cpp \ ir_print_visitor.cpp ir_variable.cpp ir_function.cpp diff --git a/ast_type.cpp b/ast_type.cpp new file mode 100644 index 00000000000..d2e047e2c43 --- /dev/null +++ b/ast_type.cpp @@ -0,0 +1,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 +#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); +} diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 52ae79918a2..e7f34864d53 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -115,77 +115,6 @@ ast_node::ast_node(void) make_empty_list(this); } -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("] "); - } -} static void ast_opt_array_size_print(bool is_array, const ast_expression *array_size) @@ -201,12 +130,6 @@ ast_opt_array_size_print(bool is_array, const ast_expression *array_size) } -ast_type_specifier::ast_type_specifier(int specifier) -{ - type_specifier = ast_types(specifier); -} - - void ast_compound_statement::print(void) const { -- 2.30.2