1 #include "ast/package.h"
3 #include "analysis/scan_imports.h"
4 #include "driver/driver.h"
7 namespace fs = std::filesystem;
9 using namespace tanlang;
11 ScanImportsOutputType ScanImports::run_impl(
Package *package) {
12 ScanImportsOutputType ret{};
16 if (node->get_node_type() == ASTNodeType::IMPORT) {
17 auto *p = pcast<Import>(node);
18 str name = p->get_name();
23 error(ErrorType::IMPORT_ERROR, node,
"Cannot find package: " + name);
25 if (fs::is_directory(res[0])) {
26 for (
const auto &entry : fs::directory_iterator(res[0])) {
27 auto path = entry.path();
28 if (!fs::is_directory(path) && path.has_extension() && path.extension() ==
".tan") {
29 ret[name].insert(path.string());
33 TAN_ASSERT(fs::exists(res[0]));
34 ret[name].insert(res[0]);
Compile a list of C++ and/or tan source files, and perform linking.
static vector< str > resolve_package_import(const str &callee_path, const str &import_name)
Get a list of possible files that corresponds to an import. Check PACKAGES.md.
vector< ASTBase * > get_children() const override
Get a ordered list of child nodes.