glsl2: Give IR nodes a type field.
This is a big deal for debugging if nothing else ("what class is this ir_instruction, really?"), but is also nice for avoiding building a whole visitor or an if (node->as_whatever() || node->as_other_thing()) chain.
This commit is contained in:
@@ -172,10 +172,25 @@ ir_validate::validate_ir(ir_instruction *ir, void *data)
|
||||
hash_table_insert(ht, ir, ir);
|
||||
}
|
||||
|
||||
void
|
||||
check_node_type(ir_instruction *ir, void *data)
|
||||
{
|
||||
if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) {
|
||||
printf("Instruction node with unset type\n");
|
||||
ir->print(); printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
validate_ir_tree(exec_list *instructions)
|
||||
{
|
||||
ir_validate v;
|
||||
|
||||
v.run(instructions);
|
||||
|
||||
foreach_iter(exec_list_iterator, iter, *instructions) {
|
||||
ir_instruction *ir = (ir_instruction *)iter.get();
|
||||
|
||||
visit_tree(ir, check_node_type, NULL);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user