summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-09-18 11:11:09 +0200
committerIan Romanick <[email protected]>2010-09-23 08:47:01 -0700
commit728829ab63209afcf5886bed47f8c95c3f045125 (patch)
treece849bb3bcba85e37c1cac414990d00621887df6 /src
parent9753ee3f3ec33cece9121e6eee11136fccf26c4e (diff)
glsl: Properly handle nested structure types.
Fixes piglit test CorrectFull.frag. (cherry picked from commit ca92ae2699c4aad21c0811b9a5562b9223816caf)
Diffstat (limited to 'src')
-rw-r--r--src/glsl/ast_to_hir.cpp31
-rw-r--r--src/glsl/glsl_parser_extras.cpp5
2 files changed, 11 insertions, 25 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 96385449bd6..0cbb4315ac0 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1534,17 +1534,12 @@ ast_type_specifier::glsl_type(const char **name,
{
const struct glsl_type *type;
- if ((this->type_specifier == ast_struct) && (this->type_name == NULL)) {
- /* FINISHME: Handle annonymous structures. */
- type = NULL;
- } else {
- type = state->symbols->get_type(this->type_name);
- *name = this->type_name;
+ type = state->symbols->get_type(this->type_name);
+ *name = this->type_name;
- if (this->is_array) {
- YYLTYPE loc = this->get_location();
- type = process_array_type(&loc, type, this->array_size, state);
- }
+ if (this->is_array) {
+ YYLTYPE loc = this->get_location();
+ type = process_array_type(&loc, type, this->array_size, state);
}
return type;
@@ -2705,7 +2700,6 @@ ast_struct_specifier::hir(exec_list *instructions,
}
}
-
/* Allocate storage for the structure fields and process the field
* declarations. As the declarations are processed, try to also convert
* the types to HIR. This ensures that structure definitions embedded in
@@ -2750,21 +2744,8 @@ ast_struct_specifier::hir(exec_list *instructions,
assert(i == decl_count);
- const char *name;
- if (this->name == NULL) {
- static unsigned anon_count = 1;
- char buf[32];
-
- snprintf(buf, sizeof(buf), "#anon_struct_%04x", anon_count);
- anon_count++;
-
- name = strdup(buf);
- } else {
- name = this->name;
- }
-
const glsl_type *t =
- glsl_type::get_record_instance(fields, decl_count, name);
+ glsl_type::get_record_instance(fields, decl_count, this->name);
YYLTYPE loc = this->get_location();
if (!state->symbols->add_type(name, t)) {
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 4ac062b42c1..33ea664bcd8 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -680,6 +680,11 @@ ast_struct_specifier::print(void) const
ast_struct_specifier::ast_struct_specifier(char *identifier,
ast_node *declarator_list)
{
+ if (identifier == NULL) {
+ static unsigned anon_count = 1;
+ identifier = talloc_asprintf(this, "#anon_struct_%04x", anon_count);
+ anon_count++;
+ }
name = identifier;
this->declarations.push_degenerate_list_at_head(&declarator_list->link);
}