diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-03-31 14:37:42 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-03-31 14:37:42 -0700 |
commit | 0bf381016524ac58f5961877ea0e8651c4922ca3 (patch) | |
tree | 5d19c7cf9e8967e12ccdc0996083e8baff0c519d | |
parent | 0ed61257253fc0df1dde9042cb0e7fe22d58077a (diff) |
glsl_type array constructor generate a real name for the type
-rw-r--r-- | glsl_types.cpp | 26 | ||||
-rw-r--r-- | glsl_types.h | 12 |
2 files changed, 28 insertions, 10 deletions
diff --git a/glsl_types.cpp b/glsl_types.cpp index 8d11196e93..eb9ab820b1 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -21,6 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ +#include <cstdio> #include <stdlib.h> #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" @@ -489,6 +490,31 @@ _mesa_glsl_initialize_constructors(exec_list *instructions, } +glsl_type::glsl_type(const glsl_type *array, unsigned length) : + base_type(GLSL_TYPE_ARRAY), + sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), + sampler_type(0), + vector_elements(0), matrix_columns(0), + name(NULL), length(length) +{ + this->fields.array = array; + + /* Allow a maximum of 10 characters for the array size. This is enough + * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating + * NUL. + */ + const unsigned name_length = strlen(array->name) + 10 + 3; + char *const n = (char *) malloc(name_length); + + if (length == 0) + snprintf(n, name_length, "%s[]", array->name); + else + snprintf(n, name_length, "%s[%u]", array->name, length); + + this->name = n; +} + + const glsl_type * glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) { diff --git a/glsl_types.h b/glsl_types.h index 6f3b512f28..23a04fbe9d 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -309,16 +309,8 @@ private: /** * Constructor for array types */ - glsl_type(const glsl_type *array, unsigned length) : - base_type(GLSL_TYPE_ARRAY), - sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), - sampler_type(0), - vector_elements(0), matrix_columns(0), - name(NULL), length(length) - { - this->fields.array = array; - this->name = "<array>"; - } + glsl_type(const glsl_type *array, unsigned length); + /** * \name Pointers to various private type singletons |