Skip to content

Commit

Permalink
Update Source.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatSageEqualToHeaven authored Mar 27, 2024
1 parent bccc913 commit 18df0db
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local table_remove = table.remove
local coroutine_create = coroutine.create
local coroutine_yield = coroutine.yield
local coroutine_resume = coroutine.resume
local coroutine_close = coroutine.close

local buffer_fromstring = buffer.fromstring
local buffer_readu8 = buffer.readu8
Expand Down Expand Up @@ -499,13 +500,19 @@ local function luau_load(module, env, luau_settings)
local interruptHook = luau_settings.callHooks.interruptHook
local panicHook = luau_settings.callHooks.panicHook

local alive = true

local function luau_close()
alive = false
end

local function luau_wrapclosure(module, proto, upvals)
local function luau_execute(debugging, stack, protos, code, varargs)
local top, pc, open_upvalues, generalized_iterators = -1, 1, {}, {}
local constants = proto.k
local extensions = luau_settings.extensions

while true do
while alive do
local inst = code[pc]
local op = inst.opcode

Expand Down Expand Up @@ -1121,6 +1128,18 @@ local function luau_load(module, env, luau_settings)
error("Unsupported Opcode: " .. inst.opname .. " op: " .. op)
end
end

for i, uv in open_upvalues do
uv.value = uv.store[uv.index]
uv.store = uv
uv.index = "value" --// self reference
open_upvalues[i] = nil
end

for i, iter in generalized_iterators do
coroutine_close(iter)
generalized_iterators[i] = nil
end
end

local function wrapped(...)
Expand Down Expand Up @@ -1162,7 +1181,7 @@ local function luau_load(module, env, luau_settings)
return wrapped
end

return luau_wrapclosure(module, mainProto)
return luau_wrapclosure(module, mainProto), luau_close
end

return {
Expand Down

0 comments on commit 18df0db

Please sign in to comment.