add experimental namespace table

This commit is contained in:
ValKmjolnir
2023-07-16 21:31:51 +08:00
parent eee30b7d8e
commit fe3847d69c
10 changed files with 185 additions and 125 deletions

View File

@@ -2,10 +2,16 @@
bool symbol_finder::visit_definition_expr(definition_expr* node) {
if (node->get_variable_name()) {
symbols.push_back(node->get_variable_name()->get_name());
symbols.push_back({
node->get_variable_name()->get_name(),
node->get_variable_name()->get_location().file
});
} else {
for(auto i : node->get_variables()->get_variables()) {
symbols.push_back(i->get_name());
symbols.push_back({
i->get_name(),
i->get_location().file
});
}
}
if (node->get_tuple()) {
@@ -22,12 +28,14 @@ bool symbol_finder::visit_function(function* node) {
bool symbol_finder::visit_iter_expr(iter_expr* node) {
if (node->get_name()) {
symbols.push_back(node->get_name()->get_name());
symbols.push_back({
node->get_name()->get_name(),
node->get_name()->get_location().file});
}
return true;
}
const std::vector<std::string>& symbol_finder::do_find(code_block* root) {
const std::vector<symbol_finder::symbol_info>& symbol_finder::do_find(code_block* root) {
symbols.clear();
root->accept(this);
return symbols;