summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-31 16:22:06 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-03-31 16:22:06 -0700
commitd612a127ccf12c11204f7f72a332de12f58f85a2 (patch)
treef6418b858b0919fbca3984525ec704c407389554
parent615adcda8a27783bac52f25fac9850a75d792c84 (diff)
Move type_specifier_to_glsl_type to ast_type_specifier::glsl_type
This make is easily accessible from other modules.
-rw-r--r--ast.h4
-rw-r--r--ast_to_hir.cpp28
2 files changed, 17 insertions, 15 deletions
diff --git a/ast.h b/ast.h
index 8e904bccc9..d21be7e7a0 100644
--- a/ast.h
+++ b/ast.h
@@ -375,6 +375,10 @@ public:
/* empty */
}
+ const struct glsl_type *glsl_type(const char **name,
+ struct _mesa_glsl_parse_state *state)
+ const;
+
virtual void print(void) const;
enum ast_types type_specifier;
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index c9aa91e7f0..5341dd59ce 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1060,22 +1060,21 @@ process_array_type(const glsl_type *base, ast_node *array_size,
}
-static const struct glsl_type *
-type_specifier_to_glsl_type(const struct ast_type_specifier *spec,
- const char **name,
- struct _mesa_glsl_parse_state *state)
+const glsl_type *
+ast_type_specifier::glsl_type(const char **name,
+ struct _mesa_glsl_parse_state *state) const
{
- const glsl_type *type;
+ const struct glsl_type *type;
- if (spec->type_specifier == ast_struct) {
+ if (this->type_specifier == ast_struct) {
/* FINISHME: Handle annonymous structures. */
type = NULL;
} else {
- type = state->symbols->get_type(spec->type_name);
- *name = spec->type_name;
+ type = state->symbols->get_type(this->type_name);
+ *name = this->type_name;
- if (spec->is_array) {
- type = process_array_type(type, spec->array_size, state);
+ if (this->is_array) {
+ type = process_array_type(type, this->array_size, state);
}
}
@@ -1142,8 +1141,7 @@ ast_declarator_list::hir(exec_list *instructions,
* FINISHME: invariant.
*/
- decl_type = type_specifier_to_glsl_type(this->type->specifier,
- & type_name, state);
+ decl_type = this->type->specifier->glsl_type(& type_name, state);
foreach (ptr, &this->declarations) {
struct ast_declaration *const decl = (struct ast_declaration * )ptr;
@@ -1368,7 +1366,7 @@ ast_parameter_declarator::hir(exec_list *instructions,
const char *name = NULL;
YYLTYPE loc = this->get_location();
- type = type_specifier_to_glsl_type(this->type->specifier, & name, state);
+ type = this->type->specifier->glsl_type(& name, state);
if (type == NULL) {
if (name != NULL) {
@@ -1465,8 +1463,8 @@ ast_function_definition::hir(exec_list *instructions,
const char *return_type_name;
const glsl_type *return_type =
- type_specifier_to_glsl_type(this->prototype->return_type->specifier,
- & return_type_name, state);
+ this->prototype->return_type->specifier->glsl_type(& return_type_name,
+ state);
assert(return_type != NULL);