summaryrefslogtreecommitdiff
path: root/glsl_types.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-31 16:30:56 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-03-31 16:30:56 -0700
commit4ef183e51de2b625b51cdd6c925760429801595e (patch)
treea733f0ab4f23d33e08265a895892bc5567e25457 /glsl_types.cpp
parent68515ee6c2a41cf5c0476b3309fcb050ef37b0d2 (diff)
Add glsl_type::generate_constructor_prototype
Generates a symbol table entry and the IR approximation of a prototype for a type's constructor. Currently only arrays are supported.
Diffstat (limited to 'glsl_types.cpp')
-rw-r--r--glsl_types.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/glsl_types.cpp b/glsl_types.cpp
index 7b8b3e9014..a38750e9bb 100644
--- a/glsl_types.cpp
+++ b/glsl_types.cpp
@@ -115,6 +115,37 @@ const glsl_type *glsl_type::get_base_type() const
}
+ir_function *
+glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const
+{
+ /* FINISHME: Add support for non-array types. */
+ assert(base_type == GLSL_TYPE_ARRAY);
+
+ /* Generate the function name and add it to the symbol table.
+ */
+ ir_function *const f = new ir_function(name);
+
+ bool added = symtab->add_function(name, f);
+ assert(added);
+
+ ir_function_signature *const sig = new ir_function_signature(this);
+ f->signatures.push_tail(sig);
+
+ for (unsigned i = 0; i < length; i++) {
+ char *const param_name = (char *) malloc(10);
+
+ snprintf(param_name, 10, "p%08X", i);
+
+ ir_variable *var = new ir_variable(fields.array, param_name);
+
+ var->mode = ir_var_in;
+ sig->parameters.push_tail(var);
+ }
+
+ return f;
+}
+
+
/**
* Generate the function intro for a constructor
*