Fix resolving top scope variables in resolve_identifiers (were considered global, but not anymore)
This commit is contained in:
parent
bcdcc9e752
commit
0d6b491fd4
1 changed files with 2 additions and 3 deletions
|
|
@ -53,7 +53,6 @@ namespace pslang::ast
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_function_scope = false;
|
bool is_function_scope = false;
|
||||||
bool is_global_scope = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct populate_globals_visitor
|
struct populate_globals_visitor
|
||||||
|
|
@ -172,7 +171,7 @@ namespace pslang::ast
|
||||||
bool crossed_function_scope = false;
|
bool crossed_function_scope = false;
|
||||||
for (auto it = scopes.rbegin(); it != scopes.rend(); ++it)
|
for (auto it = scopes.rbegin(); it != scopes.rend(); ++it)
|
||||||
{
|
{
|
||||||
if (it->contains(identifier.name, crossed_function_scope && !it->is_global_scope))
|
if (it->contains(identifier.name, crossed_function_scope))
|
||||||
{
|
{
|
||||||
identifier.level = it.base() - scopes.begin() - 1;
|
identifier.level = it.base() - scopes.begin() - 1;
|
||||||
return;
|
return;
|
||||||
|
|
@ -382,7 +381,7 @@ namespace pslang::ast
|
||||||
void resolve_identifiers(statement_list_ptr & statements)
|
void resolve_identifiers(statement_list_ptr & statements)
|
||||||
{
|
{
|
||||||
std::vector<scope> scopes;
|
std::vector<scope> scopes;
|
||||||
scopes.emplace_back().is_global_scope = true;
|
scopes.emplace_back();
|
||||||
resolve_identifiers_visitor visitor{{}, {}, {}, scopes};
|
resolve_identifiers_visitor visitor{{}, {}, {}, scopes};
|
||||||
visitor.apply(*statements);
|
visitor.apply(*statements);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue