diff options
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/raw.lua | 29 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 5 |
2 files changed, 34 insertions, 0 deletions
diff --git a/server/src/vm/raw.lua b/server/src/vm/raw.lua new file mode 100644 index 00000000..31a8e8d1 --- /dev/null +++ b/server/src/vm/raw.lua @@ -0,0 +1,29 @@ +local mt = require 'vm.manager' + +function mt:callRawSet(func, values, source) + local tbl = values[1] + local index = values[2] + local value = values[3] + if not tbl or not index or not value then + return + end + if index:getLiteral() then + index = index:getLiteral() + end + tbl:addInfo('set child', source, index) + tbl:rawSet(index, value, source) +end + +function mt:callRawGet(func, values, source) + local tbl = values[1] + local index = values[2] + if not tbl or not index then + return + end + if index:getLiteral() then + index = index:getLiteral() + end + tbl:addInfo('get child', source, index) + local value = tbl:rawGet(index) + func:setReturn(1, value) +end diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index dfdac390..1f9f4e83 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -11,6 +11,7 @@ local config = require 'config' local mt = require 'vm.manager' require 'vm.module' +require 'vm.raw' -- TODO source测试 --rawset(_G, 'CachedSource', setmetatable({}, { __mode = 'kv' })) @@ -277,6 +278,10 @@ function mt:callLibrary(func, values, source, lib) self:callModuel(func, values) elseif lib.special == 'seeall' then self:callSeeAll(func, values) + elseif lib.special == 'rawset' then + self:callRawSet(func, values, source) + elseif lib.special == 'rawget' then + self:callRawGet(func, values, source) end else -- 如果lib的参数中有function,则立即执行function |