summaryrefslogtreecommitdiff
path: root/server-beta/src
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src')
-rw-r--r--server-beta/src/searcher/eachField.lua34
-rw-r--r--server-beta/src/searcher/eachRef.lua21
2 files changed, 48 insertions, 7 deletions
diff --git a/server-beta/src/searcher/eachField.lua b/server-beta/src/searcher/eachField.lua
index c40d78eb..320fd9f2 100644
--- a/server-beta/src/searcher/eachField.lua
+++ b/server-beta/src/searcher/eachField.lua
@@ -1,19 +1,19 @@
-local function ofLocal(seacher, source, callback)
+local function ofLocal(searcher, source, callback)
if source.ref then
for _, ref in ipairs(source.ref) do
if ref.type == 'getlocal' then
local parent = ref.parent
- local field = seacher:getField(parent)
+ local field = searcher:getField(parent)
if field then
callback {
- seacher = seacher,
+ searcher = searcher,
source = field,
}
end
elseif ref.type == 'getglobal'
or ref.type == 'setglobal' then
callback {
- seacher = seacher,
+ searcher = searcher,
source = ref,
}
end
@@ -21,11 +21,31 @@ local function ofLocal(seacher, source, callback)
end
end
-return function (seacher, source, callback)
+local function ofGlobal(searcher, source, callback)
+ searcher:eachRef(source, function (info)
+ local src = info.source
+ if src.type == 'getglobal' then
+ if src.parent then
+ local field = info.searcher:getField(src.parent)
+ if field then
+ callback {
+ searcher = info.searcher,
+ source = field,
+ }
+ end
+ end
+ end
+ end)
+end
+
+return function (searcher, source, callback)
if source.type == 'local' then
- ofLocal(seacher, source, callback)
+ ofLocal(searcher, source, callback)
elseif source.type == 'getlocal'
or source.type == 'setlocal' then
- ofLocal(seacher, source.node, callback)
+ ofLocal(searcher, source.node, callback)
+ elseif source.type == 'getglobal'
+ or source.type == 'setglobal' then
+ ofGlobal(searcher, source, callback)
end
end
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua
index 63720ec9..8230914e 100644
--- a/server-beta/src/searcher/eachRef.lua
+++ b/server-beta/src/searcher/eachRef.lua
@@ -66,6 +66,15 @@ local function checkField(key, info, callback)
elseif parent.type == 'getmethod' then
mode = 'get'
end
+ elseif src.type == 'number'
+ or src.type == 'string'
+ or src.type == 'boolean' then
+ local parent = src.parent
+ if parent.type == 'setindex' then
+ mode = 'set'
+ elseif parent.type == 'getindex' then
+ mode = 'get'
+ end
end
if mode then
callback {
@@ -93,6 +102,14 @@ local function ofField(searcher, source, callback)
end)
end
+local function ofLiteral(searcher, source, callback)
+ local parent = source.parent
+ if parent.type == 'setindex'
+ or parent.type == 'getindex' then
+ ofField(searcher, source, callback)
+ end
+end
+
return function (searcher, source, callback)
local stype = source.type
if stype == 'local' then
@@ -107,5 +124,9 @@ return function (searcher, source, callback)
or stype == 'method'
or stype == 'index' then
ofField(searcher, source, callback)
+ elseif stype == 'number'
+ or stype == 'boolean'
+ or stype == 'string' then
+ ofLiteral(searcher, source, callback)
end
end