aboutsummaryrefslogtreecommitdiff
path: root/src/yuescript/yue_compiler.cpp
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-07-13 14:46:55 +0800
committerLi Jin <dragon-fly@qq.com>2022-07-13 14:46:55 +0800
commita1d341085eed96d567329a30f2cf57c95fe6f071 (patch)
tree37d359a02b99cf94fa52cfc43eb9c5c80ecfeb89 /src/yuescript/yue_compiler.cpp
parentaa194667c7cb7bb70f2a58477555d1419ae33eb0 (diff)
downloadyuescript-a1d341085eed96d567329a30f2cf57c95fe6f071.tar.gz
yuescript-a1d341085eed96d567329a30f2cf57c95fe6f071.tar.bz2
yuescript-a1d341085eed96d567329a30f2cf57c95fe6f071.zip
auto add search path for cmd tools.
Diffstat (limited to '')
-rwxr-xr-xsrc/yuescript/yue_compiler.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index c7ceeb4..c68746c 100755
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -56,7 +56,7 @@ using namespace parserlib;
56 56
57typedef std::list<std::string> str_list; 57typedef std::list<std::string> str_list;
58 58
59const std::string_view version = "0.13.2"sv; 59const std::string_view version = "0.13.3"sv;
60const std::string_view extension = "yue"sv; 60const std::string_view extension = "yue"sv;
61 61
62class YueCompilerImpl { 62class YueCompilerImpl {
@@ -6887,13 +6887,23 @@ private:
6887 DEFER(lua_settop(L, top)); 6887 DEFER(lua_settop(L, top));
6888 pushYue("find_modulepath"sv); // cur find_modulepath 6888 pushYue("find_modulepath"sv); // cur find_modulepath
6889 lua_pushlstring(L, moduleName.c_str(), moduleName.size()); // cur find_modulepath moduleName 6889 lua_pushlstring(L, moduleName.c_str(), moduleName.size()); // cur find_modulepath moduleName
6890 if (lua_pcall(L, 1, 1, 0) != 0) { 6890 if (lua_pcall(L, 1, 2, 0) != 0) {
6891 std::string err = lua_tostring(L, -1); 6891 std::string err = lua_tostring(L, -1);
6892 throw std::logic_error(_info.errorMessage("failed to resolve module path\n"s + err, x)); 6892 throw std::logic_error(_info.errorMessage("failed to resolve module path\n"s + err, x));
6893 } 6893 }
6894 if (lua_isnil(L, -1) != 0) { 6894 if (lua_isnil(L, -2) != 0) {
6895 throw std::logic_error(_info.errorMessage("failed to find module '"s + moduleName + '\'', x)); 6895 str_list files;
6896 if (lua_istable(L, -1) != 0) {
6897 int size = static_cast<int>(lua_objlen(L, -1));
6898 for (int i = 0; i < size; i++) {
6899 lua_rawgeti(L, -1, i + 1);
6900 files.push_back("no file \""s + lua_tostring(L, -1) + "\""s);
6901 lua_pop(L, 1);
6902 }
6903 }
6904 throw std::logic_error(_info.errorMessage("module '"s + moduleName + "\' not found:\n\t"s + join(files, "\n\t"sv), x));
6896 } 6905 }
6906 lua_pop(L, 1);
6897 std::string moduleFullName = lua_tostring(L, -1); 6907 std::string moduleFullName = lua_tostring(L, -1);
6898 lua_pop(L, 1); // cur 6908 lua_pop(L, 1); // cur
6899 if (!isModuleLoaded(moduleFullName)) { 6909 if (!isModuleLoaded(moduleFullName)) {