glsl: Add unary ir_expression constructor
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 9 Nov 2010 22:19:10 +0000 (14:19 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 19 Nov 2010 23:00:25 +0000 (15:00 -0800)
src/glsl/ir.cpp
src/glsl/ir.h

index 308b7c2010dc97fffec95cb9690e260a2a797e76..1f5e2ebdcb732572a886c677172ade0c67cd9c06 100644 (file)
@@ -191,9 +191,22 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
 }
 
 
+ir_expression::ir_expression(int op, const struct glsl_type *type,
+                            ir_rvalue *op0)
+{
+   assert(get_num_operands(ir_expression_operation(op)) == 1);
+   this->ir_type = ir_type_expression;
+   this->type = type;
+   this->operation = ir_expression_operation(op);
+   this->operands[0] = op0;
+   this->operands[1] = NULL;
+}
+
 ir_expression::ir_expression(int op, const struct glsl_type *type,
                             ir_rvalue *op0, ir_rvalue *op1)
 {
+   assert((op1 == NULL) && (get_num_operands(ir_expression_operation(op)) == 1)
+         || (get_num_operands(ir_expression_operation(op)) == 2));
    this->ir_type = ir_type_expression;
    this->type = type;
    this->operation = ir_expression_operation(op);
index 960cd8bab433a45378fe99ced85848bc1778e408..99fdaa3b09b918b81d0f9b4ba452d57892a3df8a 100644 (file)
@@ -832,6 +832,14 @@ enum ir_expression_operation {
 
 class ir_expression : public ir_rvalue {
 public:
+   /**
+    * Constructor for unary operation expressions
+    */
+   ir_expression(int op, const struct glsl_type *type, ir_rvalue *);
+
+   /**
+    * Constructor for binary operation expressions
+    */
    ir_expression(int op, const struct glsl_type *type,
                 ir_rvalue *, ir_rvalue *);