InterfaceGenerator::InterfaceGenerator():
- stage(0)
+ stage(0),
+ function_scope(false)
{ }
string InterfaceGenerator::get_out_prefix(Stage::Type type)
{
if(var.interface=="out")
{
- if(current_block!=&stage->content && generate_interface(var, "out", change_prefix(var.name, string())))
+ /* For out variables in function scope, generate a global interface and
+ replace the local declaration with an assignment. */
+ if(function_scope && generate_interface(var, "out", var.name))
{
nodes_to_remove.insert(&var);
if(var.init_expression)
}
else if(var.interface=="in")
{
- if(!var.linked_declaration && stage->previous)
+ /* Try to link in variables in global scope with out variables from
+ previous stage */
+ if(current_block==&stage->content && !var.linked_declaration && stage->previous)
{
const map<string, VariableDeclaration *> &prev_vars = stage->previous->content.variables;
map<string, VariableDeclaration *>::const_iterator i = prev_vars.find(var.name);
void InterfaceGenerator::visit(FunctionDeclaration &func)
{
+ SetFlag set_scope(function_scope, true);
// Skip parameters because they're not useful here
func.body.visit(*this);
}