aboutsummaryrefslogtreecommitdiff
path: root/src/yue_wasm.cpp
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-09-14 16:44:18 +0800
committerLi Jin <dragon-fly@qq.com>2023-09-14 16:44:18 +0800
commit42f973f85ba7e3934111aa53588b43049c123a56 (patch)
treefee574b27aca27607972b0a35cffa3a77c4b9a22 /src/yue_wasm.cpp
parent103fd0646eb83898b37398731f90e2dc277ac2d8 (diff)
downloadyuescript-42f973f85ba7e3934111aa53588b43049c123a56.tar.gz
yuescript-42f973f85ba7e3934111aa53588b43049c123a56.tar.bz2
yuescript-42f973f85ba7e3934111aa53588b43049c123a56.zip
fixing issue #148.
Diffstat (limited to '')
-rw-r--r--src/yue_wasm.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/yue_wasm.cpp b/src/yue_wasm.cpp
index 1b614e3..4a054e6 100644
--- a/src/yue_wasm.cpp
+++ b/src/yue_wasm.cpp
@@ -140,15 +140,16 @@ std::string exec(const std::string& codes) {
140 execStr(R"yuescript( 140 execStr(R"yuescript(
141_G.__output = {} 141_G.__output = {}
142_G.print = (...)-> 142_G.print = (...)->
143 len = select "#", ... 143 _G.__output[] = table.concat [tostring select i, ... for i = 1, select "#", ...], " "
144 strs = {} 144 _G.__output[] = "\n"
145 for i = 1, len 145_io_write = io.write
146 strs[#strs + 1] = tostring select i, ... 146_G.io.write = (...)->
147 _G.__output[#_G.__output + 1] = table.concat strs, "\n" 147 _G.__output[] = table.concat [tostring select i, ... for i = 1, select "#", ...]
148 _io_write ...
148 )yuescript"); 149 )yuescript");
149 std::string res2 = execStr(codes); 150 std::string res2 = execStr(codes);
150 std::string res1 = execStr(R"yuescript( 151 std::string res1 = execStr(R"yuescript(
151res = table.concat _G.__output, "\n" 152res = table.concat _G.__output
152return res if res ~= "" 153return res if res ~= ""
153 )yuescript"); 154 )yuescript");
154 if (res1.empty()) { 155 if (res1.empty()) {