summaryrefslogtreecommitdiff
path: root/server-beta/src/searcher/eachField.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/searcher/eachField.lua')
-rw-r--r--server-beta/src/searcher/eachField.lua67
1 files changed, 48 insertions, 19 deletions
diff --git a/server-beta/src/searcher/eachField.lua b/server-beta/src/searcher/eachField.lua
index 8fea864e..98f7fd69 100644
--- a/server-beta/src/searcher/eachField.lua
+++ b/server-beta/src/searcher/eachField.lua
@@ -1,19 +1,15 @@
+local guide = require 'parser.guide'
+
local function ofTabel(searcher, value, callback)
for _, field in ipairs(value) do
- if field.type == 'tablefield' then
- callback {
- searcher = searcher,
- source = field.field,
- }
- elseif field.type == 'tableindex' then
- callback {
- searcher = searcher,
- source = field.index,
- }
- else
+ if field.type == 'tablefield'
+ or field.type == 'tableindex' then
callback {
searcher = searcher,
source = field,
+ key = guide.getKeyName(field),
+ value = field.value,
+ mode = 'set',
}
end
end
@@ -27,14 +23,25 @@ local function ofENV(searcher, source, callback)
or parent.type == 'getindex' then
callback {
searcher = searcher,
- source = parent,
+ source = parent,
+ key = guide.getKeyName(parent),
+ mode = 'get',
}
end
- elseif source.type == 'getglobal'
- or source.type == 'setglobal' then
+ elseif source.type == 'getglobal' then
callback {
searcher = searcher,
- source = source,
+ source = source,
+ key = guide.getKeyName(source),
+ mode = 'get',
+ }
+ elseif source.type == 'setglobal' then
+ callback {
+ searcher = searcher,
+ source = source,
+ key = guide.getKeyName(source),
+ mode = 'set',
+ value = source.value,
}
end
end
@@ -46,13 +53,24 @@ local function ofVar(searcher, source, callback)
end
if parent.type == 'getfield'
or parent.type == 'getmethod'
- or parent.type == 'getindex'
- or parent.type == 'setfield'
+ or parent.type == 'getindex' then
+ callback {
+ searcher = searcher,
+ source = parent,
+ key = guide.getKeyName(parent),
+ mode = 'get',
+ }
+ return
+ end
+ if parent.type == 'setfield'
or parent.type == 'setmethod'
or parent.type == 'setindex' then
callback {
searcher = searcher,
source = parent,
+ key = guide.getKeyName(parent),
+ value = parent.value,
+ mode = 'set',
}
return
end
@@ -60,12 +78,23 @@ local function ofVar(searcher, source, callback)
local call = parent.parent
local func = call.node
local name = searcher:getSpecialName(func)
- if name == 'rawset'
- or name == 'rawget' then
+ if name == 'rawset' then
+ if parent[1] == source then
+ callback {
+ searcher = searcher,
+ source = call,
+ key = guide.getKeyName(parent[2]),
+ value = parent[3],
+ mode = 'set',
+ }
+ end
+ elseif name == 'rawget' then
if parent[1] == source then
callback {
searcher = searcher,
source = call,
+ key = guide.getKeyName(parent[2]),
+ mode = 'get',
}
end
end