🐛 fix error report bug in import.cpp
This commit is contained in:
parent
f7f4a38b47
commit
9f7484596a
|
@ -8,6 +8,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <sstream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// abbreviation of some useful basic type
|
// abbreviation of some useful basic type
|
||||||
|
|
|
@ -198,8 +198,10 @@ code_block* linker::import_regular_file(call_expr* node) {
|
||||||
return new code_block({0, 0, 0, 0, filename});
|
return new code_block({0, 0, 0, 0, filename});
|
||||||
}
|
}
|
||||||
if (check_self_import(filename)) {
|
if (check_self_import(filename)) {
|
||||||
err.err("link", "self-referenced module <" + filename + ">:\n" +
|
err.err("link",
|
||||||
" reference path: " + generate_self_import_path(filename));
|
"self-referenced module <" + filename + ">:\n" +
|
||||||
|
" reference path: " + generate_self_import_path(filename)
|
||||||
|
);
|
||||||
return new code_block({0, 0, 0, 0, filename});
|
return new code_block({0, 0, 0, 0, filename});
|
||||||
}
|
}
|
||||||
exist(filename);
|
exist(filename);
|
||||||
|
@ -208,16 +210,19 @@ code_block* linker::import_regular_file(call_expr* node) {
|
||||||
// start importing...
|
// start importing...
|
||||||
if (lex.scan(filename).geterr()) {
|
if (lex.scan(filename).geterr()) {
|
||||||
err.err("link", "error occurred when analysing <" + filename + ">");
|
err.err("link", "error occurred when analysing <" + filename + ">");
|
||||||
|
return new code_block({0, 0, 0, 0, filename});
|
||||||
}
|
}
|
||||||
if (par.compile(lex).geterr()) {
|
if (par.compile(lex).geterr()) {
|
||||||
err.err("link", "error occurred when analysing <" + filename + ">");
|
err.err("link", "error occurred when analysing <" + filename + ">");
|
||||||
|
return new code_block({0, 0, 0, 0, filename});
|
||||||
}
|
}
|
||||||
auto tmp = par.swap(nullptr);
|
|
||||||
|
|
||||||
// check if tmp has 'import'
|
auto parse_result = par.swap(nullptr);
|
||||||
auto res = load(tmp, find(filename));
|
|
||||||
|
// check if parse result has 'import'
|
||||||
|
auto result = load(parse_result, find(filename));
|
||||||
module_load_stack.pop_back();
|
module_load_stack.pop_back();
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
code_block* linker::import_nasal_lib() {
|
code_block* linker::import_nasal_lib() {
|
||||||
|
@ -239,16 +244,18 @@ code_block* linker::import_nasal_lib() {
|
||||||
err.err("link",
|
err.err("link",
|
||||||
"error occurred when analysing library <" + filename + ">"
|
"error occurred when analysing library <" + filename + ">"
|
||||||
);
|
);
|
||||||
|
return new code_block({0, 0, 0, 0, filename});
|
||||||
}
|
}
|
||||||
if (par.compile(lex).geterr()) {
|
if (par.compile(lex).geterr()) {
|
||||||
err.err("link",
|
err.err("link",
|
||||||
"error occurred when analysing library <" + filename + ">"
|
"error occurred when analysing library <" + filename + ">"
|
||||||
);
|
);
|
||||||
|
return new code_block({0, 0, 0, 0, filename});
|
||||||
}
|
}
|
||||||
auto tmp = par.swap(nullptr);
|
|
||||||
|
|
||||||
// check if tmp has 'import'
|
auto parse_result = par.swap(nullptr);
|
||||||
return load(tmp, find(filename));
|
// check if library has 'import' (in fact it should not)
|
||||||
|
return load(parse_result, find(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string linker::generate_module_name(const std::string& file_path) {
|
std::string linker::generate_module_name(const std::string& file_path) {
|
||||||
|
|
Loading…
Reference in New Issue