This felt hacky, and also seemed wrong since the variable map contains
the original names of the variables, not new ones. Instead avoid
inlining more than one function per pass into any given function.
inlined.push_back(r_inlined_statement);
}
inlined.push_back(r_inlined_statement);
}
- // Insert the variables here to enable further inlinings to avoid conflicts.
- tgt_blk.variables.insert(variable_map.begin(), variable_map.end());
-
SetForScope<unsigned> set_remap(remap_names, 1);
SetForScope<string> set_prefix(remap_prefix, target_func.name);
variable_map.clear();
SetForScope<unsigned> set_remap(remap_names, 1);
SetForScope<string> set_prefix(remap_prefix, target_func.name);
variable_map.clear();
FunctionInliner::FunctionInliner():
current_function(0),
FunctionInliner::FunctionInliner():
current_function(0),
+ r_any_inlined(false),
+ r_inlined_here(false)
{ }
bool FunctionInliner::apply(Stage &s)
{ }
bool FunctionInliner::apply(Stage &s)
{
SetForScope<Block *> set_block(current_block, &block);
SetForScope<NodeList<Statement>::iterator> save_insert_point(insert_point, block.body.begin());
{
SetForScope<Block *> set_block(current_block, &block);
SetForScope<NodeList<Statement>::iterator> save_insert_point(insert_point, block.body.begin());
- for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
+ for(NodeList<Statement>::iterator i=block.body.begin(); (!r_inlined_here && i!=block.body.end()); ++i)
{
insert_point = i;
(*i)->visit(*this);
{
insert_point = i;
(*i)->visit(*this);
void FunctionInliner::visit(FunctionCall &call)
{
void FunctionInliner::visit(FunctionCall &call)
{
+ if(r_inlined_here)
+ return;
+
for(NodeArray<Expression>::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i)
visit(*i);
for(NodeArray<Expression>::iterator i=call.arguments.begin(); i!=call.arguments.end(); ++i)
visit(*i);
/* Inlined variables need to be resolved before this function can be
inlined further. */
inlineable.erase(current_function);
/* Inlined variables need to be resolved before this function can be
inlined further. */
inlineable.erase(current_function);
{
SetForScope<FunctionDeclaration *> set_func(current_function, &func);
TraversingVisitor::visit(func);
{
SetForScope<FunctionDeclaration *> set_func(current_function, &func);
TraversingVisitor::visit(func);
+ r_inlined_here = false;
}
void FunctionInliner::visit(Iteration &iter)
}
void FunctionInliner::visit(Iteration &iter)
NodeList<Statement>::iterator insert_point;
RefPtr<Expression> r_inline_result;
bool r_any_inlined;
NodeList<Statement>::iterator insert_point;
RefPtr<Expression> r_inline_result;
bool r_any_inlined;
public:
FunctionInliner();
public:
FunctionInliner();