diff options
-rw-r--r-- | server-beta/src/core/local.lua | 47 | ||||
-rw-r--r-- | server-beta/test/definition/set.lua | 18 |
2 files changed, 30 insertions, 35 deletions
diff --git a/server-beta/src/core/local.lua b/server-beta/src/core/local.lua index 1a9c1644..113637a9 100644 --- a/server-beta/src/core/local.lua +++ b/server-beta/src/core/local.lua @@ -1,3 +1,5 @@ +local guide = require 'parser.guide' + local m = {} function m:def(source, callback) @@ -43,23 +45,7 @@ function m:field(source, key, callback) for _, ref in ipairs(source.ref) do if ref.type == 'getlocal' then local parent = ref.parent - local tp = parent.type - if tp == 'setfield' - or tp == 'setmethod' - or tp == 'setindex' then - callback(parent, 'set') - elseif tp == 'getfield' - or tp == 'getmethod' - or tp == 'getindex' then - callback(parent, 'get') - end - elseif ref.type == 'setlocal' then - self:eachRef(ref.value, 'field', callback) - elseif ref.type == 'getglobal' then - -- _ENV.XXX - callback(ref, 'get') - if self:getSpecial(ref) == 's|_G' then - local parent = ref.parent + if key == guide.getKeyName(parent) then local tp = parent.type if tp == 'setfield' or tp == 'setmethod' @@ -71,20 +57,29 @@ function m:field(source, key, callback) callback(parent, 'get') end end + elseif ref.type == 'setlocal' then + self:eachRef(ref.value, 'field', callback) + elseif ref.type == 'getglobal' then + -- _ENV.XXX + if key == guide.getKeyName(ref) then + callback(ref, 'get') + end elseif ref.type == 'setglobal' then -- _ENV.XXX = XXX - callback(ref, 'set') + if key == guide.getKeyName(ref) then + callback(ref, 'set') + end end end end - if source.tag == 'self' then - local method = source.method - local node = method.node - self:eachRef(node, 'field', callback) - end - if source.value then - self:eachField(source.value, nil, 'ref', callback) - end + --if source.tag == 'self' then + -- local method = source.method + -- local node = method.node + -- self:eachRef(node, 'field', callback) + --end + --if source.value then + -- self:eachField(source.value, nil, 'ref', callback) + --end end return m diff --git a/server-beta/test/definition/set.lua b/server-beta/test/definition/set.lua index be653baa..ca2c0828 100644 --- a/server-beta/test/definition/set.lua +++ b/server-beta/test/definition/set.lua @@ -44,12 +44,12 @@ TEST [[ print(<?x?>) ]] -TEST [[ -<!_G.x!> = 1 -print(<?x?>) -]] - -TEST [[ -<!rawset(_G, 'x', 1)!> -print(<?x?>) -]] +--TEST [[ +--<!_G.x!> = 1 +--print(<?x?>) +--]] +-- +--TEST [[ +--<!rawset(_G, 'x', 1)!> +--print(<?x?>) +--]] |