diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-29 10:09:13 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-29 10:09:13 +0800 |
commit | 2490ce5d8b5770370fb31619a8151b0211320385 (patch) | |
tree | 28c89245dc0e7a97f0b1ee4357c909be4b2bc666 /server/src | |
parent | 70e4776a011ce894d9aedafc4108d9e175f41b80 (diff) | |
download | lua-language-server-2490ce5d8b5770370fb31619a8151b0211320385.zip |
setField操作不会访问__index元表
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/core/vm.lua | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua index 004e40f9..69aa4a43 100644 --- a/server/src/core/vm.lua +++ b/server/src/core/vm.lua @@ -707,6 +707,7 @@ function mt:getName(name, source) if loc then return loc end + source.uri = self.uri local ENV = self.scope.locals._ENV local ENVValue = self:getValue(ENV) local global = ENVValue:getField(name, source) or ENVValue:createField(name, source) @@ -841,11 +842,15 @@ function mt:getSimple(simple, mode) elseif tp == 'index' then local child = obj[1] local index = self:getIndex(child) - field = value:getField(index, child) or value:createField(index, child) - field.parentValue = value - value = self:getValue(field) if mode == 'value' or i < #simple then + field = value:getField(index, child) or value:createField(index, child) + field.parentValue = value + value = self:getValue(field) self:addInfo(field, 'get', obj) + else + field = value:createField(index, child) + field.parentValue = value + value = self:getValue(field) end field.parent = lastField lastField = field @@ -859,11 +864,15 @@ function mt:getSimple(simple, mode) parentName = ('%s[?]'):format(parentName) end elseif tp == 'name' then - field = value:getField(obj[1], obj) or value:createField(obj[1], obj) - field.parentValue = value - value = self:getValue(field) if mode == 'value' or i < #simple then + field = value:getField(obj[1], obj) or value:createField(obj[1], obj) + field.parentValue = value + value = self:getValue(field) self:addInfo(field, 'get', obj) + else + field = value:createField(obj[1], obj) + field.parentValue = value + value = self:getValue(field) end field.parent = lastField lastField = field |