diff options
Diffstat (limited to 'server/src/vm')
-rw-r--r-- | server/src/vm/multi.lua | 14 | ||||
-rw-r--r-- | server/src/vm/source.lua | 9 | ||||
-rw-r--r-- | server/src/vm/value.lua | 2 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 8 |
4 files changed, 28 insertions, 5 deletions
diff --git a/server/src/vm/multi.lua b/server/src/vm/multi.lua index ffaae1c0..93900a36 100644 --- a/server/src/vm/multi.lua +++ b/server/src/vm/multi.lua @@ -4,8 +4,18 @@ local mt = {} mt.__index = mt mt.type = 'multi' -function mt:push(value) - self[#self+1] = value +function mt:push(value, isLast) + if value.type == 'list' then + if isLast then + for _, v in ipairs(value) do + self[#self+1] = v + end + else + self[#self+1] = value[1] + end + else + self[#self+1] = value + end end function mt:get(index) diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua index e2de6a27..1e9001d1 100644 --- a/server/src/vm/source.lua +++ b/server/src/vm/source.lua @@ -26,6 +26,15 @@ function mt:bindFunction(func) end end +function mt:bindValue(value, action) + if value then + self._bindValue = value + value:addInfo(action, self) + else + return self._bindValue + end +end + function mt:setUri(uri) self._uri = uri end diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index f8824db6..1079c206 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -184,7 +184,7 @@ function mt:addInfo(tp, source) if source and not source.start then error('Miss start: ' .. table.dump(source)) end - self[#self] = { + self[#self+1] = { type = tp, source = source or getDefaultSource(), } diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 62f057d2..3d53feee 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -450,6 +450,7 @@ function mt:getSimple(simple, max) local first = simple[1] self:instantSource(first) local value = self:getExp(first) + first:bindValue(value, 'get') if not max then max = #simple elseif max < 0 then @@ -472,8 +473,10 @@ function mt:getSimple(simple, max) local child = source[1] local index = self:getIndex(child) value = value:getChild(index) or createValue('any') + source:bindValue(value, 'get') elseif source.type == 'name' then value = value:getChild(source[1]) or createValue('any') + source:bindValue(value, 'get') elseif source.type == ':' then object = value elseif source.type == '.' then @@ -664,8 +667,8 @@ end function mt:getMultiByList(list) local multi = createMulti() - for _, exp in ipairs(list) do - multi:push(self:getExp(exp)) + for i, exp in ipairs(list) do + multi:push(self:getExp(exp), i == #list) end return multi end @@ -722,6 +725,7 @@ function mt:setOne(var, value) value = createValue('nil') end self:instantSource(var) + var:bindValue(value, 'set') if var.type == 'name' then self:setName(var[1], var, value) elseif var.type == 'simple' then |