summaryrefslogtreecommitdiff
path: root/ir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-06-09 17:18:04 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-06-11 13:51:42 -0700
commit710919fd7cb7ac6cb640afa362f5c409e5a5ec91 (patch)
treed8dd21dda49155d24169cbd06793f89211c2f9c7 /ir.cpp
parent7f1ab834d7aa901ce0e12f40db23d7d9891eae59 (diff)
ir_constant: Support constant structures in clone
Diffstat (limited to 'ir.cpp')
-rw-r--r--ir.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/ir.cpp b/ir.cpp
index b60d1b468a..bb1c4589a5 100644
--- a/ir.cpp
+++ b/ir.cpp
@@ -184,6 +184,11 @@ ir_expression::get_operator(const char *str)
return (ir_expression_operation) -1;
}
+ir_constant::ir_constant()
+{
+ /* empty */
+}
+
ir_constant::ir_constant(const struct glsl_type *type, const void *data)
{
unsigned size = 0;
@@ -301,6 +306,37 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
}
}
+ir_constant *
+ir_constant::clone()
+{
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ case GLSL_TYPE_INT:
+ case GLSL_TYPE_FLOAT:
+ case GLSL_TYPE_BOOL:
+ return new ir_constant(this->type, &this->value);
+
+ case GLSL_TYPE_STRUCT: {
+ ir_constant *c = new ir_constant;
+
+ c->type = this->type;
+ for (exec_node *node = this->components.head
+ ; !node->is_tail_sentinal()
+ ; node = node->next) {
+ ir_constant *const orig = (ir_constant *) node;
+
+ c->components.push_tail(orig->clone());
+ }
+
+ return c;
+ }
+
+ default:
+ assert(!"Should not get here."); break;
+ return NULL;
+ }
+}
+
bool
ir_constant::get_bool_component(unsigned i) const
{