diff options
author | Li Jin <dragon-fly@qq.com> | 2021-01-11 10:11:47 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-01-11 10:11:47 +0800 |
commit | 4937e32a628b6950f698f147a121bac6376dd3ba (patch) | |
tree | 9fb05545062fc72065b9a84f1a68424e1e5b266e | |
parent | 843d43f57a52948cf33d126582a01085ffc33421 (diff) | |
download | yuescript-4937e32a628b6950f698f147a121bac6376dd3ba.tar.gz yuescript-4937e32a628b6950f698f147a121bac6376dd3ba.tar.bz2 yuescript-4937e32a628b6950f698f147a121bac6376dd3ba.zip |
fix issue #34.
-rw-r--r-- | src/MoonP/moon_compiler.cpp | 3 | ||||
-rw-r--r-- | src/moonp.cpp | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 75f1b35..d49cf14 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
@@ -53,7 +53,7 @@ inline std::string s(std::string_view sv) { | |||
53 | return std::string(sv); | 53 | return std::string(sv); |
54 | } | 54 | } |
55 | 55 | ||
56 | const std::string_view version = "0.4.21"sv; | 56 | const std::string_view version = "0.4.22"sv; |
57 | const std::string_view extension = "mp"sv; | 57 | const std::string_view extension = "mp"sv; |
58 | 58 | ||
59 | class MoonCompilerImpl { | 59 | class MoonCompilerImpl { |
@@ -106,6 +106,7 @@ public: | |||
106 | str_list out; | 106 | str_list out; |
107 | pushScope(); | 107 | pushScope(); |
108 | _enableReturn.push(_info.moduleName.empty()); | 108 | _enableReturn.push(_info.moduleName.empty()); |
109 | _varArgs.push(true); | ||
109 | transformBlock(_info.node.to<File_t>()->block, out, | 110 | transformBlock(_info.node.to<File_t>()->block, out, |
110 | config.implicitReturnRoot ? ExpUsage::Return : ExpUsage::Common, | 111 | config.implicitReturnRoot ? ExpUsage::Return : ExpUsage::Common, |
111 | nullptr, true); | 112 | nullptr, true); |
diff --git a/src/moonp.cpp b/src/moonp.cpp index 30cbe43..27c6016 100644 --- a/src/moonp.cpp +++ b/src/moonp.cpp | |||
@@ -331,7 +331,14 @@ int main(int narg, const char** args) { | |||
331 | lua_pop(L, 1); | 331 | lua_pop(L, 1); |
332 | pushMoonp(L, "pcall"sv); | 332 | pushMoonp(L, "pcall"sv); |
333 | lua_insert(L, -2); | 333 | lua_insert(L, -2); |
334 | if (lua_pcall(L, 1, 2, 0) != 0) { | 334 | int argCount = 0; |
335 | i++; | ||
336 | while (i < narg) { | ||
337 | argCount++; | ||
338 | lua_pushstring(L, args[i]); | ||
339 | i++; | ||
340 | } | ||
341 | if (lua_pcall(L, 1 + argCount, 2, 0) != 0) { | ||
335 | std::cout << lua_tostring(L, -1) << '\n'; | 342 | std::cout << lua_tostring(L, -1) << '\n'; |
336 | return 1; | 343 | return 1; |
337 | } | 344 | } |