![]() |
User Guide
|
Visitor to rename local variables conflicting with global scope More...
Visitor to rename local variables conflicting with global scope
Motivation: During inlining we have to do data-flow-analysis. Consider below example:
When rates() will be inlined into states(), local definition of tau will conflict with range variable tau. Hence we can't just copy the statements. Dataflow analysis could be done at the time of inlining. Other way is to run this pass before inlining and pre-rename any local-global variable conflicts. As we are renaming local variables only, it's safe and there are no side effects.
Definition at line 63 of file local_var_rename_visitor.hpp.
#include <local_var_rename_visitor.hpp>
Private Attributes | |
const symtab::SymbolTable * | symtab = nullptr |
non-null symbol table in the scope hierarchy More... | |
std::stack< const symtab::SymbolTable * > | symtab_stack |
symbol tables in case of nested blocks More... | |
std::map< std::string, int > | renamed_variables |
variables currently being renamed and their count More... | |
|
default |
|
overridevirtual |
rename name conflicting variables in the statement block and it's all children
nothing to do
go back to previous block in hierarchy
global blocks do not change (do no have parent symbol table) if no variables in the block then there is nothing to do
if symbol is a variable name (avoid renaming use of units like mV)
Implements nmodl::visitor::Visitor.
Definition at line 23 of file local_var_rename_visitor.cpp.
|
private |
variables currently being renamed and their count
Definition at line 72 of file local_var_rename_visitor.hpp.
|
private |
non-null symbol table in the scope hierarchy
Definition at line 66 of file local_var_rename_visitor.hpp.
|
private |
symbol tables in case of nested blocks
Definition at line 69 of file local_var_rename_visitor.hpp.