aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compat53/init.lua28
1 files changed, 5 insertions, 23 deletions
diff --git a/compat53/init.lua b/compat53/init.lua
index b952003..96b6c67 100644
--- a/compat53/init.lua
+++ b/compat53/init.lua
@@ -206,37 +206,19 @@ if lua_version == "5.1" then
206 end -- debug table available 206 end -- debug table available
207 207
208 208
209 local main_coroutine = coroutine_create(function() end)
210
211 if not is_luajit52 then 209 if not is_luajit52 then
210 local coroutine_running52 = M.coroutine.running
212 function M.coroutine.running() 211 function M.coroutine.running()
213 local co = coroutine_running() 212 local co, ismain = coroutine_running52()
214 if co then 213 if ismain then
215 return pcall_mainOf[co] or co, false 214 return co, true
216 else 215 else
217 return main_coroutine, true 216 return pcall_mainOf[co] or co, false
218 end 217 end
219 end 218 end
220 end 219 end
221 220
222 if not is_luajit then 221 if not is_luajit then
223 function M.coroutine.resume(co, ...)
224 if co == main_coroutine then
225 return false, "cannot resume non-suspended coroutine"
226 else
227 return coroutine_resume(co, ...)
228 end
229 end
230
231 function M.coroutine.status(co)
232 local notmain = coroutine_running()
233 if co == main_coroutine then
234 return notmain and "normal" or "running"
235 else
236 return coroutine_status(co)
237 end
238 end
239
240 local function pcall_results(current, call, success, ...) 222 local function pcall_results(current, call, success, ...)
241 if coroutine_status(call) == "suspended" then 223 if coroutine_status(call) == "suspended" then
242 return pcall_results(current, call, coroutine_resume(call, coroutine_yield(...))) 224 return pcall_results(current, call, coroutine_resume(call, coroutine_yield(...)))