diff options
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/function.lua | 10 | ||||
-rw-r--r-- | server/src/vm/library.lua | 8 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 4 |
3 files changed, 15 insertions, 7 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 5b7d8682..8e2478ca 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -3,6 +3,8 @@ local valueMgr = require 'vm.value' local localMgr = require 'vm.local' local sourceMgr = require 'vm.source' +local Watch = setmetatable({}, {__mode = 'kv'}) + local mt = {} mt.__index = mt mt.type = 'function' @@ -267,7 +269,7 @@ function mt:getSource() return sourceMgr.list[self.source] end -return function (source) +local function create(source) local id if source then id = source.id @@ -283,5 +285,11 @@ return function (source) argValues = {}, }, mt) self:push(source) + Watch[self] = true return self end + +return { + create = create, + watch = Watch, +} diff --git a/server/src/vm/library.lua b/server/src/vm/library.lua index 54dca81f..ed5c2e7f 100644 --- a/server/src/vm/library.lua +++ b/server/src/vm/library.lua @@ -1,7 +1,7 @@ local sourceMgr = require 'vm.source' local valueMgr -local createFunction +local functionMgr local CHILD_CACHE = {} local VALUE_CACHE = {} @@ -15,7 +15,7 @@ function buildLibValue(lib) end if not valueMgr then valueMgr = require 'vm.value' - createFunction = require 'vm.function' + functionMgr = require 'vm.function' end local tp = lib.type local value @@ -23,7 +23,7 @@ function buildLibValue(lib) value = valueMgr.create('table', sourceMgr.dummy()) elseif tp == 'function' then value = valueMgr.create('function', sourceMgr.dummy()) - local func = createFunction() + local func = functionMgr.create() value:setFunction(func) if lib.args then for _, arg in ipairs(lib.args) do @@ -69,7 +69,7 @@ end function buildLibChild(lib) if not valueMgr then valueMgr = require 'vm.value' - createFunction = require 'vm.function' + functionMgr = require 'vm.function' end if CHILD_CACHE[lib] then return CHILD_CACHE[lib] diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 940e822f..4ca7b64b 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -2,7 +2,7 @@ local library = require 'core.library' local valueMgr = require 'vm.value' local localMgr = require 'vm.local' local createLabel = require 'vm.label' -local createFunction = require 'vm.function' +local functionMgr = require 'vm.function' local sourceMgr = require 'vm.source' local buildGlobal = require 'vm.global' local createMulti = require 'vm.multi' @@ -1008,7 +1008,7 @@ end function mt:createFunction(source) local value = self:createValue('function', source) - local func = createFunction(source) + local func = functionMgr.create(source) value:setFunction(func) value:setType('function', 1.0) if source:getUri() == self.uri then |