Variables have types, expression trees have types, but statements don't.
Rather than have a nonsensical field that stays NULL in the base class,
just move it to where it makes sense.
Fix up a few places that lazily used ir_instruction even though they
actually knew the particular subclass.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
const char *comma = "";
foreach_list(node, parameters) {
- const ir_instruction *const param = (ir_instruction *) node;
+ const ir_variable *const param = (ir_variable *) node;
ralloc_asprintf_append(&str, "%s%s", comma, param->type->name);
comma = ", ";
class ir_instruction : public exec_node {
public:
enum ir_node_type ir_type;
- const struct glsl_type *type;
/** ir_print_visitor helper for debugging. */
void print(void) const;
ir_instruction()
{
ir_type = ir_type_unset;
- type = NULL;
}
};
*/
class ir_rvalue : public ir_instruction {
public:
+ const struct glsl_type *type;
+
virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const;
virtual void accept(ir_visitor *v)
*/
glsl_interp_qualifier determine_interpolation_mode(bool flat_shade);
+ /**
+ * Declared type of the variable
+ */
+ const struct glsl_type *type;
+
/**
* Delcared name of the variable
*/
const ir_variable *const param = (ir_variable *) node_a;
- const ir_instruction *const actual = (ir_instruction *) node_b;
+ const ir_rvalue *const actual = (ir_rvalue *) node_b;
if (param->type == actual->type)
continue;
printf("Instruction node with unset type\n");
ir->print(); printf("\n");
}
- assert(ir->type != glsl_type::error_type);
+ ir_rvalue *value = ir->as_rvalue();
+ if (value != NULL)
+ assert(value->type != glsl_type::error_type);
}
void
}
static inline bool
-is_array_or_matrix(const ir_instruction *ir)
+is_array_or_matrix(const ir_rvalue *ir)
{
return (ir->type->is_array() || ir->type->is_matrix());
}
}
} else if (ir->type->is_record()) {
foreach_list(node, &ir->components) {
- ir_instruction *const field = (ir_instruction *) node;
+ ir_constant *const field = (ir_constant *) node;
const unsigned size = type_size(field->type);
field->accept(this);