diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 17:57:51 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 17:57:51 +0800 |
commit | 170d7a2894ca9cb758edc9f75343889552d07e0c (patch) | |
tree | d2f822a4f4b7b6caf5465b08f06fadc020946479 /server/src/core | |
parent | 144a34923f5bcafdea10d8e3c04ca6d04c6354f7 (diff) | |
download | lua-language-server-170d7a2894ca9cb758edc9f75343889552d07e0c.zip |
用表来过滤
Diffstat (limited to 'server/src/core')
-rw-r--r-- | server/src/core/value.lua | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/server/src/core/value.lua b/server/src/core/value.lua index ad3a48e8..2c364b62 100644 --- a/server/src/core/value.lua +++ b/server/src/core/value.lua @@ -126,21 +126,21 @@ function mt:setChild(child) self._child = child end -function mt:getField(name, source, stack) +function mt:getField(name, source, mark) local field = self:rawGetField(name, source) if not field then local indexMeta = self:getMeta('__index', source) if not indexMeta then return nil end - if not stack then - stack = 0 + if not mark then + mark = {} end - stack = stack + 1 - if stack > 10 then + if mark[indexMeta] then return nil end - return indexMeta.value:getField(name, source, stack) + mark[indexMeta] = true + return indexMeta.value:getField(name, source, mark) end return field end @@ -158,7 +158,7 @@ function mt:rawEachField(callback) return nil end -function mt:eachField(callback, stack) +function mt:eachField(callback, stack, mark) local res = self:rawEachField(callback) if res ~= nil then return res @@ -167,14 +167,14 @@ function mt:eachField(callback, stack) if not indexMeta then return nil end - if not stack then - stack = 0 + if not mark then + mark = {} end - stack = stack + 1 - if stack > 10 then + if mark[indexMeta] then return nil end - return indexMeta.value:eachField(callback, stack) + mark[indexMeta] = true + return indexMeta.value:eachField(callback, stack, mark) end function mt:removeUri(uri) |