diff options
-rw-r--r-- | src/yue_wasm.cpp | 13 |
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( |
151 | res = table.concat _G.__output, "\n" | 152 | res = table.concat _G.__output |
152 | return res if res ~= "" | 153 | return res if res ~= "" |
153 | )yuescript"); | 154 | )yuescript"); |
154 | if (res1.empty()) { | 155 | if (res1.empty()) { |