[FEAT] Implemented 'if' support
[BUG] Variables inside blocks couldn't shadow those outside [FEAT] Decompiler shows address of each opcode
This commit is contained in:
15
scope.cpp
15
scope.cpp
@@ -69,11 +69,18 @@ const int scope_declare_variable(const std::string name, const uint32_t type, co
|
||||
return address;
|
||||
}
|
||||
|
||||
const bool scope_variable_exists(const std::string name) {
|
||||
const bool scope_variable_exists(const std::string name, const bool can_shadow) {
|
||||
t_scope& scope = (are_we_inside_local ? local : global);
|
||||
for (t_variable v : scope.variables) if (v.name == name) {
|
||||
current_var = &v;
|
||||
return true;
|
||||
if (are_we_inside_local && can_shadow) {
|
||||
for (int i = blocks.top(); i < scope.variables.size(); i++ ) if (scope.variables[i].name == name) {
|
||||
current_var = &scope.variables[i];
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
for (t_variable v : scope.variables) if (v.name == name) {
|
||||
current_var = &v;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user