apply<InterfaceGenerator>(stage);
apply<VariableResolver>(stage);
apply<VariableRenamer>(stage);
+ apply<DeclarationReorderer>(stage);
apply<LegacyConverter>(stage);
}
}
+ProgramCompiler::DeclarationReorderer::DeclarationReorderer():
+ kind(NO_DECLARATION)
+{ }
+
+void ProgramCompiler::DeclarationReorderer::visit(Block &block)
+{
+ list<RefPtr<Node> >::iterator struct_insert_point = block.body.end();
+ list<RefPtr<Node> >::iterator variable_insert_point = block.body.end();
+
+ for(list<RefPtr<Node> >::iterator i=block.body.begin(); i!=block.body.end(); )
+ {
+ kind = NO_DECLARATION;
+ (*i)->visit(*this);
+
+ bool moved = false;
+ if(kind==STRUCT && struct_insert_point!=block.body.end())
+ {
+ block.body.insert(struct_insert_point, *i);
+ moved = true;
+ }
+ else if(kind>STRUCT && struct_insert_point==block.body.end())
+ struct_insert_point = i;
+
+ if(kind==VARIABLE && variable_insert_point!=block.body.end())
+ {
+ block.body.insert(variable_insert_point, *i);
+ moved = true;
+ }
+ else if(kind>VARIABLE && variable_insert_point==block.body.end())
+ variable_insert_point = i;
+
+ if(moved)
+ block.body.erase(i++);
+ else
+ ++i;
+ }
+}
+
+
ProgramCompiler::ExpressionEvaluator::ExpressionEvaluator():
variable_values(0),
result(0.0f),