aboutsummaryrefslogtreecommitdiff
path: root/include/elna/boot/dependency.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/elna/boot/dependency.h')
-rw-r--r--include/elna/boot/dependency.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/elna/boot/dependency.h b/include/elna/boot/dependency.h
index 195d37a..a87503e 100644
--- a/include/elna/boot/dependency.h
+++ b/include/elna/boot/dependency.h
@@ -149,6 +149,16 @@ namespace elna::boot
std::filesystem::path build_path(const std::vector<std::string>& segments);
/**
+ * Symbols brought in by one import declaration, paired with the position
+ * of the declaration that requested them.
+ */
+ struct module_import
+ {
+ source_position position;
+ std::shared_ptr<symbol_table> symbols;
+ };
+
+ /**
* Analyzes a module semantically: collects type declarations, resolves
* names, checks types and validates the module.
*
@@ -165,7 +175,7 @@ namespace elna::boot
* \return Module scope and diagnostics.
*/
analysis_result analyze_semantics(std::unique_ptr<unit>& tree,
- const std::vector<std::shared_ptr<symbol_table>>& imports,
+ const std::vector<module_import>& imports,
const std::shared_ptr<symbol_table>& globals, const target_info& target,
const std::filesystem::path& module_path);
@@ -257,7 +267,7 @@ namespace elna::boot
return result;
}
auto& tree = std::get<std::unique_ptr<unit>>(parsed);
- std::vector<std::shared_ptr<symbol_table>> imports;
+ std::vector<module_import> imports;
diagnostic_list circular;
if (imported && tree->entry_point.has_value())
@@ -289,7 +299,10 @@ namespace elna::boot
{
result.append(std::move(diagnostics.module), std::move(diagnostics.errors()));
}
- imports.push_back(this->cache.find(module_path)->second.exported_symbols());
+ imports.push_back({
+ .position = sub_tree->position(),
+ .symbols = this->cache.find(module_path)->second.exported_symbols()
+ });
}
result.append(key, std::move(circular));
analysis_result analysis = analyze_semantics(tree, imports, this->globals, target, key);