[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:
2021-05-05 15:16:57 +02:00
parent 8b101e4d3c
commit 287bf565bd
6 changed files with 108 additions and 114 deletions

View File

@@ -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;
}