summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/main.lua2
-rw-r--r--server/src/vm/function.lua18
-rw-r--r--server/src/vm/value.lua7
3 files changed, 26 insertions, 1 deletions
diff --git a/server/main.lua b/server/main.lua
index 685fce01..ac7860c5 100644
--- a/server/main.lua
+++ b/server/main.lua
@@ -22,7 +22,7 @@ local function tryDebugger()
log.info('Debugger startup, listen port: 11411')
end
-pcall(tryDebugger)
+--pcall(tryDebugger)
require 'utility'
require 'global_protect'
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua
index 9453defa..9dcc1f02 100644
--- a/server/src/vm/function.lua
+++ b/server/src/vm/function.lua
@@ -118,6 +118,9 @@ function mt:setReturn(index, value)
if value then
self.returns[index] = value
end
+ if self._global then
+ value:markGlobal()
+ end
end
function mt:mergeReturn(index, value)
@@ -136,6 +139,9 @@ function mt:mergeReturn(index, value)
self.returns[index] = value
end
end
+ if self._global then
+ value:markGlobal()
+ end
end
function mt:getReturn(index)
@@ -308,6 +314,18 @@ function mt:kill()
listMgr.clear(self.id)
end
+function mt:markGlobal()
+ if self._global then
+ return
+ end
+ self._global = true
+ if self.returns then
+ self.returns:eachValue(function (_, v)
+ v:markGlobal()
+ end)
+ end
+end
+
local function create(source)
if not source then
error('Function need source')
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index c93fda90..2a1c14d1 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -446,6 +446,9 @@ end
function mt:setFunction(func)
self._func = func.id
+ if self._global then
+ func:markGlobal()
+ end
end
function mt:getFunction()
@@ -502,6 +505,10 @@ function mt:markGlobal()
self:rawEach(function (index, value)
value:markGlobal()
end)
+ local func = self:getFunction()
+ if func then
+ func:markGlobal()
+ end
end
function mt:isGlobal()