diff options
author | Timothy Arceri <[email protected]> | 2014-01-23 23:22:01 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2014-01-23 23:37:37 +1100 |
commit | b0c64d3cc6d1d3a64c86a5b2cd748b4178bff350 (patch) | |
tree | 71b1f532d7cbcca9f829cbc9891a08735800f9c6 | |
parent | 61a584609936940f69207dd520b5b4208810a9e7 (diff) |
glsl: remove remaining is_array variables
Previously the reason we needed is_array was because we used array_size == NULL to
represent both non-arrays and unsized arrays. Now that we use a non-NULL
array_specifier to represent an unsized array, is_array is redundant.
Signed-off-by: Timothy Arceri <[email protected]>
Reviewed-by: Paul Berry <[email protected]>
-rw-r--r-- | src/glsl/ast.h | 32 | ||||
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 11 | ||||
-rw-r--r-- | src/glsl/ast_type.cpp | 6 | ||||
-rw-r--r-- | src/glsl/glsl_parser.yy | 30 | ||||
-rw-r--r-- | src/glsl/glsl_parser_extras.cpp | 15 |
5 files changed, 35 insertions, 59 deletions
diff --git a/src/glsl/ast.h b/src/glsl/ast.h index d462dd59763..0bda28d20dd 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -371,14 +371,13 @@ public: class ast_declaration : public ast_node { public: - ast_declaration(const char *identifier, bool is_array, + ast_declaration(const char *identifier, ast_array_specifier *array_specifier, ast_expression *initializer); virtual void print(void) const; const char *identifier; - - bool is_array; + ast_array_specifier *array_specifier; ast_expression *initializer; @@ -588,10 +587,10 @@ public: * Use only if the objects are allocated from the same context and will not * be modified. Zeros the inherited ast_node's fields. */ - ast_type_specifier(const ast_type_specifier *that, bool is_array, + ast_type_specifier(const ast_type_specifier *that, ast_array_specifier *array_specifier) : ast_node(), type_name(that->type_name), structure(that->structure), - is_array(is_array), array_specifier(array_specifier), + array_specifier(array_specifier), default_precision(that->default_precision) { /* empty */ @@ -599,8 +598,7 @@ public: /** Construct a type specifier from a type name */ ast_type_specifier(const char *name) - : type_name(name), structure(NULL), - is_array(false), array_specifier(NULL), + : type_name(name), structure(NULL), array_specifier(NULL), default_precision(ast_precision_none) { /* empty */ @@ -608,8 +606,7 @@ public: /** Construct a type specifier from a structure definition */ ast_type_specifier(ast_struct_specifier *s) - : type_name(s->name), structure(s), - is_array(false), array_specifier(NULL), + : type_name(s->name), structure(s), array_specifier(NULL), default_precision(ast_precision_none) { /* empty */ @@ -626,7 +623,6 @@ public: const char *type_name; ast_struct_specifier *structure; - bool is_array; ast_array_specifier *array_specifier; /** For precision statements, this is the given precision; otherwise none. */ @@ -680,7 +676,6 @@ public: ast_parameter_declarator() : type(NULL), identifier(NULL), - is_array(false), array_specifier(NULL), formal_parameter(false), is_void(false) @@ -695,7 +690,6 @@ public: ast_fully_specified_type *type; const char *identifier; - bool is_array; ast_array_specifier *array_specifier; static void parameters_to_hir(exec_list *ast_parameters, @@ -943,13 +937,10 @@ class ast_interface_block : public ast_node { public: ast_interface_block(ast_type_qualifier layout, const char *instance_name, - bool is_array, ast_array_specifier *array_specifier) : layout(layout), block_name(NULL), instance_name(instance_name), - is_array(is_array), array_specifier(array_specifier) + array_specifier(array_specifier) { - if (!is_array) - assert(array_specifier == NULL); } virtual ir_rvalue *hir(exec_list *instructions, @@ -970,15 +961,6 @@ public: exec_list declarations; /** - * True if the block is declared as an array - * - * \note - * A block can only be an array if it also has an instance name. If this - * field is true, ::instance_name must also not be \c NULL. - */ - bool is_array; - - /** * Declared array size of the block instance * * If the block is not declared as an array or if the block instance array diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index f13ac51c164..c71078ede1e 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2874,7 +2874,6 @@ ast_declarator_list::hir(exec_list *instructions, } foreach_list_typed (ast_declaration, decl, link, &this->declarations) { - assert(!decl->is_array); assert(decl->array_specifier == NULL); assert(decl->initializer == NULL); @@ -4507,7 +4506,7 @@ ast_type_specifier::hir(exec_list *instructions, return NULL; } - if (this->is_array) { + if (this->array_specifier != NULL) { _mesa_glsl_error(&loc, state, "default precision statements do not apply to " "arrays"); @@ -4924,7 +4923,7 @@ ast_interface_block::hir(exec_list *instructions, _mesa_shader_stage_to_string(state->stage)); } if (this->instance_name == NULL || - strcmp(this->instance_name, "gl_in") != 0 || !this->is_array) { + strcmp(this->instance_name, "gl_in") != 0 || this->array_specifier == NULL) { _mesa_glsl_error(&loc, state, "gl_PerVertex input must be redeclared as " "gl_in[]"); @@ -5026,7 +5025,7 @@ ast_interface_block::hir(exec_list *instructions, * variable (or input block, see interface blocks below) needs to be * declared as an array. */ - if (state->stage == MESA_SHADER_GEOMETRY && !this->is_array && + if (state->stage == MESA_SHADER_GEOMETRY && this->array_specifier == NULL && var_mode == ir_var_shader_in) { _mesa_glsl_error(&loc, state, "geometry shader inputs must be arrays"); } @@ -5060,7 +5059,7 @@ ast_interface_block::hir(exec_list *instructions, ir_variable *var; - if (this->is_array) { + if (this->array_specifier != NULL) { /* Section 4.3.7 (Interface Blocks) of the GLSL 1.50 spec says: * * For uniform blocks declared an array, each individual array @@ -5121,7 +5120,7 @@ ast_interface_block::hir(exec_list *instructions, /* In order to have an array size, the block must also be declared with * an instane name. */ - assert(!this->is_array); + assert(this->array_specifier == NULL); for (unsigned i = 0; i < num_variables; i++) { ir_variable *var = diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index 0dd1180c37f..637da0dfb7c 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -32,10 +32,8 @@ ast_type_specifier::print(void) const printf("%s ", type_name); } - if (is_array) { - if (array_specifier) { - array_specifier->print(); - } + if (array_specifier) { + array_specifier->print(); } } diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index 2786e920922..928c57e20d1 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -977,7 +977,7 @@ init_declarator_list: | init_declarator_list ',' any_identifier { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL); + ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL); decl->set_location(yylloc); $$ = $1; @@ -987,7 +987,7 @@ init_declarator_list: | init_declarator_list ',' any_identifier array_specifier { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, true, $4, NULL); + ast_declaration *decl = new(ctx) ast_declaration($3, $4, NULL); decl->set_location(yylloc); $$ = $1; @@ -997,7 +997,7 @@ init_declarator_list: | init_declarator_list ',' any_identifier array_specifier '=' initializer { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, true, $4, $6); + ast_declaration *decl = new(ctx) ast_declaration($3, $4, $6); decl->set_location(yylloc); $$ = $1; @@ -1007,7 +1007,7 @@ init_declarator_list: | init_declarator_list ',' any_identifier '=' initializer { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5); + ast_declaration *decl = new(ctx) ast_declaration($3, NULL, $5); decl->set_location(yylloc); $$ = $1; @@ -1028,7 +1028,7 @@ single_declaration: | fully_specified_type any_identifier { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); + ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL); $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); @@ -1037,7 +1037,7 @@ single_declaration: | fully_specified_type any_identifier array_specifier { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, true, $3, NULL); + ast_declaration *decl = new(ctx) ast_declaration($2, $3, NULL); $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); @@ -1046,7 +1046,7 @@ single_declaration: | fully_specified_type any_identifier array_specifier '=' initializer { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, true, $3, $5); + ast_declaration *decl = new(ctx) ast_declaration($2, $3, $5); $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); @@ -1055,7 +1055,7 @@ single_declaration: | fully_specified_type any_identifier '=' initializer { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); + ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4); $$ = new(ctx) ast_declarator_list($1); $$->set_location(yylloc); @@ -1064,7 +1064,7 @@ single_declaration: | INVARIANT variable_identifier // Vertex only. { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); + ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL); $$ = new(ctx) ast_declarator_list(NULL); $$->set_location(yylloc); @@ -1771,13 +1771,13 @@ struct_declarator: any_identifier { void *ctx = state; - $$ = new(ctx) ast_declaration($1, false, NULL, NULL); + $$ = new(ctx) ast_declaration($1, NULL, NULL); $$->set_location(yylloc); } | any_identifier array_specifier { void *ctx = state; - $$ = new(ctx) ast_declaration($1, true, $2, NULL); + $$ = new(ctx) ast_declaration($1, $2, NULL); $$->set_location(yylloc); } ; @@ -1935,7 +1935,7 @@ condition: | fully_specified_type any_identifier '=' initializer { void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); + ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4); ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); decl->set_location(yylloc); declarator->set_location(yylloc); @@ -2270,17 +2270,17 @@ instance_name_opt: /* empty */ { $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, - NULL, false, NULL); + NULL, NULL); } | NEW_IDENTIFIER { $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, - $1, false, NULL); + $1, NULL); } | NEW_IDENTIFIER array_specifier { $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, - $1, true, $2); + $1, $2); } ; diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index ceb42b61722..ba1c969724d 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -790,12 +790,10 @@ ast_node::ast_node(void) static void -ast_opt_array_dimensions_print(bool is_array, const ast_array_specifier *array_specifier) +ast_opt_array_dimensions_print(const ast_array_specifier *array_specifier) { - if (is_array) { - if (array_specifier) - array_specifier->print(); - } + if (array_specifier) + array_specifier->print(); } @@ -1018,7 +1016,7 @@ ast_parameter_declarator::print(void) const type->print(); if (identifier) printf("%s ", identifier); - ast_opt_array_dimensions_print(is_array, array_specifier); + ast_opt_array_dimensions_print(array_specifier); } @@ -1034,7 +1032,7 @@ void ast_declaration::print(void) const { printf("%s ", identifier); - ast_opt_array_dimensions_print(is_array, array_specifier); + ast_opt_array_dimensions_print(array_specifier); if (initializer) { printf("= "); @@ -1043,12 +1041,11 @@ ast_declaration::print(void) const } -ast_declaration::ast_declaration(const char *identifier, bool is_array, +ast_declaration::ast_declaration(const char *identifier, ast_array_specifier *array_specifier, ast_expression *initializer) { this->identifier = identifier; - this->is_array = is_array; this->array_specifier = array_specifier; this->initializer = initializer; } |