![]() |
User Guide
|
Blindly
rename given variable to new name
More...
Blindly
rename given variable to new name
During inlining related passes we have to rename variables to avoid name conflicts. This pass "blindly" rename any given variable to new name. The error handling / legality checks are supposed to be done by other higher level passes. For example, local renaming pass should be done from inner-most block to top level block;
Definition at line 43 of file rename_visitor.hpp.
#include <rename_visitor.hpp>
Private Attributes | |
std::shared_ptr< ast::Program > | ast |
ast::Ast* node More... | |
std::regex | var_name_regex |
regex for searching which variables to replace More... | |
std::string | new_var_name |
new name More... | |
std::string | new_var_name_prefix |
variable prefix More... | |
std::unordered_map< std::string, std::string > | renamed_variables |
Map that keeps the renamed variables to keep the same random suffix when a variable is renamed across the whole file. More... | |
bool | add_prefix = false |
add prefix to variable name More... | |
bool | add_random_suffix = false |
add random suffix More... | |
bool | rename_verbatim = true |
rename verbatim blocks as well More... | |
|
default |
|
inline |
Definition at line 73 of file rename_visitor.hpp.
|
inline |
Definition at line 77 of file rename_visitor.hpp.
|
inlinenoexcept |
Definition at line 102 of file rename_visitor.hpp.
std::string nmodl::visitor::RenameVisitor::new_name_generator | ( | const std::string & | old_name | ) |
Check if variable is already renamed and use the same naming otherwise add the new_name to the renamed_variables map.
Definition at line 20 of file rename_visitor.cpp.
|
inline |
Definition at line 97 of file rename_visitor.hpp.
|
overridevirtual |
rename matching variable
Implements nmodl::visitor::ConstVisitor.
Definition at line 48 of file rename_visitor.cpp.
|
overridevirtual |
Prime name has member order which is an integer.
In theory integer could be "macro name" and hence could end-up renaming macro. In practice this won't be an issue as we order is set by parser. To be safe we are only renaming prime variable.
Implements nmodl::visitor::ConstVisitor.
Definition at line 69 of file rename_visitor.cpp.
|
overridevirtual |
Parse verbatim blocks and rename variable if it is used.
Check if variable is already renamed and use the same naming otherwise add the new_name to the renamed_variables map
Implements nmodl::visitor::ConstVisitor.
Definition at line 76 of file rename_visitor.cpp.
|
private |
add prefix to variable name
Definition at line 62 of file rename_visitor.hpp.
|
private |
add random suffix
Definition at line 65 of file rename_visitor.hpp.
|
private |
ast::Ast* node
Definition at line 46 of file rename_visitor.hpp.
|
private |
new name
Definition at line 52 of file rename_visitor.hpp.
|
private |
variable prefix
Definition at line 55 of file rename_visitor.hpp.
|
private |
rename verbatim blocks as well
Definition at line 68 of file rename_visitor.hpp.
|
private |
Map that keeps the renamed variables to keep the same random suffix when a variable is renamed across the whole file.
Definition at line 59 of file rename_visitor.hpp.
|
private |
regex for searching which variables to replace
Definition at line 49 of file rename_visitor.hpp.