Skip to content

Commit af2e3f4

Browse files
committed
symbols in build.lab no longer cause conflicts, support for faster symbol resolution and declaration by caching, user can also import selected symbols instead of all
1 parent 56a274e commit af2e3f4

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

compiler/ASTProcessor.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,6 @@ int ASTProcessor::sym_res_module(LabModule* module) {
394394
int ASTProcessor::sym_res_module_seq(LabModule* module) {
395395
const auto mod_index = resolver->module_scope_start();
396396

397-
// declare symbols of directly imported modules
398-
399-
SymbolResolverShadowDeclarer declarer(*resolver);
400-
for(const auto dep : module->dependencies) {
401-
for(auto& file_ptr : dep->direct_files) {
402-
auto& file = *file_ptr.result;
403-
for(const auto node : file.unit.scope.body.nodes) {
404-
declare_node(declarer, node, AccessSpecifier::Public);
405-
}
406-
}
407-
}
408-
409397
// declare symbols for all files once in the module
410398

411399
for(auto& file_ptr : module->direct_files) {

compiler/symres/DeclareTopLevel.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ static void append_alias_and_part(Diag& d, const std::vector<chem::string_view>&
6363
void declareChildren(SymbolResolver& linker, ChildrenMapNode* node, ImportStatement* stmt) {
6464
auto& import_items = stmt->getImportItems();
6565
if(import_items.empty() && !stmt->is_force_empty_import_items()) {
66-
linker.declare(stmt->getTopLevelAlias(), node);
66+
auto& alias = stmt->getTopLevelAlias();
67+
if(alias.empty()) {
68+
// user asked to declare all the symbols
69+
for(auto& sym : node->symbols) {
70+
linker.declare_or_shadow(sym.first, sym.second);
71+
}
72+
} else {
73+
linker.declare(alias, node);
74+
}
6775
return;
6876
} else {
6977
auto& symbols = node->symbols;
@@ -103,7 +111,6 @@ void declareChildren(SymbolResolver& linker, ChildrenMapNode* node, ImportStatem
103111
}
104112

105113
void TopLevelDeclSymDeclare::VisitImportStmt(ImportStatement* stmt) {
106-
if(stmt->getTopLevelAlias().empty()) return;
107114
switch(stmt->getResultKind()) {
108115
case ImportResultKind::None:
109116
linker.error(stmt) << "couldn't import file/module '" << stmt->getSourcePath() << "' because of missing result";

0 commit comments

Comments
 (0)