Refactor ir_dereference support for ir_visitor

Move the accept method for visitors from ir_dereference to the derived
classes.
This commit is contained in:
Ian Romanick
2010-05-19 13:20:12 +02:00
parent f3a002b503
commit c7b1046a9f
9 changed files with 176 additions and 104 deletions

View File

@@ -67,7 +67,9 @@ public:
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
virtual void visit(ir_dereference *);
virtual void visit(ir_dereference_variable *);
virtual void visit(ir_dereference_array *);
virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
@@ -412,16 +414,28 @@ ir_constant_visitor::visit(ir_swizzle *ir)
void
ir_constant_visitor::visit(ir_dereference *ir)
ir_constant_visitor::visit(ir_dereference_variable *ir)
{
value = NULL;
if (ir->mode == ir_dereference::ir_reference_variable) {
ir_variable *var = ir->var->as_variable();
if (var && var->constant_value) {
value = new ir_constant(ir->type, &var->constant_value->value);
}
}
ir_variable *var = ir->variable_referenced();
if (var && var->constant_value)
value = new ir_constant(ir->type, &var->constant_value->value);
}
void
ir_constant_visitor::visit(ir_dereference_array *ir)
{
value = NULL;
/* FINISHME: Other dereference modes. */
}
void
ir_constant_visitor::visit(ir_dereference_record *ir)
{
value = NULL;
/* FINISHME: Other dereference modes. */
}