summaryrefslogtreecommitdiff
path: root/server-beta
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta')
-rw-r--r--server-beta/src/core/engineer.lua21
-rw-r--r--server-beta/src/core/getfield.lua49
-rw-r--r--server-beta/src/core/getglobal.lua49
3 files changed, 61 insertions, 58 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua
index 7bde9e4e..4f29d1ea 100644
--- a/server-beta/src/core/engineer.lua
+++ b/server-beta/src/core/engineer.lua
@@ -289,6 +289,27 @@ function mt:callReturnOf(source)
end
end
+function mt:childMode(source)
+ if source.type == 'getfield' then
+ return source.field, 'get'
+ elseif source.type == 'setfield' then
+ return source.field, 'set'
+ elseif source.type == 'getmethod' then
+ return source.method, 'get'
+ elseif source.type == 'setmethod' then
+ return source.method, 'set'
+ elseif source.type == 'getindex' then
+ return source.index, 'get'
+ elseif source.type == 'setindex' then
+ return source.index, 'set'
+ elseif source.type == 'field' then
+ return self:childMode(source.parent)
+ elseif source.type == 'method' then
+ return self:childMode(source.parent)
+ end
+ return nil, nil
+end
+
return function (ast)
local self = setmetatable({
step = 0,
diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua
index 4cc5d3f8..aa07719b 100644
--- a/server-beta/src/core/getfield.lua
+++ b/server-beta/src/core/getfield.lua
@@ -19,38 +19,29 @@ function m:field(source, key, callback)
self:eachRef(source, function (src)
used[src] = true
- if src.type == 'getfield' then
- if guide.getKeyName(src.field) == key then
- callback(src.field, 'get')
+ local child, mode = self:childMode(src)
+ if child then
+ if key == guide.getKeyName(child) then
+ callback(child, mode)
end
- elseif src.type == 'setfield' then
- if guide.getKeyName(src.field) == key then
- callback(src.field, 'set')
- end
- elseif src.type == 'getmethod' then
- if guide.getKeyName(src.method) == key then
- callback(src.method, 'get')
- end
- elseif src.type == 'setmethod' then
- if guide.getKeyName(src.method) == key then
- callback(src.method, 'set')
- end
- elseif src.type == 'getindex' then
- if guide.getKeyName(src.index) == key then
- callback(src.index, 'get')
- end
- elseif src.type == 'setindex' then
- if guide.getKeyName(src.index) == key then
- callback(src.index, 'set')
- end
- elseif src.type == 'getglobal' then
- if guide.getKeyName(src.parent) == key then
- callback(src.parent, 'get')
+ return
+ end
+ if src.type == 'getglobal' then
+ local parent = src.parent
+ child, mode = self:childMode(parent)
+ if child then
+ if key == guide.getKeyName(child) then
+ callback(child, mode)
+ end
end
elseif src.type == 'setglobal' then
- --if guide.getKeyName(src.parent) == key then
- -- callback(src.parent, 'set')
- --end
+ local parent = src.parent
+ child, mode = self:childMode(parent)
+ if child then
+ if key == guide.getKeyName(child) then
+ callback(child, mode)
+ end
+ end
else
self:eachField(src, key, callback)
end
diff --git a/server-beta/src/core/getglobal.lua b/server-beta/src/core/getglobal.lua
index a8bcb04c..a6814a7d 100644
--- a/server-beta/src/core/getglobal.lua
+++ b/server-beta/src/core/getglobal.lua
@@ -68,38 +68,29 @@ function m:field(source, key, callback)
self:eachRef(source, function (src)
used[src] = true
- if src.type == 'getfield' then
- if guide.getKeyName(src.field) == key then
- callback(src.field, 'get')
+ local child, mode = self:childMode(src)
+ if child then
+ if key == guide.getKeyName(child) then
+ callback(child, mode)
end
- elseif src.type == 'setfield' then
- if guide.getKeyName(src.field) == key then
- callback(src.field, 'set')
- end
- elseif src.type == 'getmethod' then
- if guide.getKeyName(src.method) == key then
- callback(src.method, 'get')
- end
- elseif src.type == 'setmethod' then
- if guide.getKeyName(src.method) == key then
- callback(src.method, 'set')
- end
- elseif src.type == 'getindex' then
- if guide.getKeyName(src.index) == key then
- callback(src.index, 'get')
- end
- elseif src.type == 'setindex' then
- if guide.getKeyName(src.index) == key then
- callback(src.index, 'set')
- end
- elseif src.type == 'getglobal' then
- if guide.getKeyName(src.parent) == key then
- callback(src.parent, 'get')
+ return
+ end
+ if src.type == 'getglobal' then
+ local parent = src.parent
+ child, mode = self:childMode(parent)
+ if child then
+ if key == guide.getKeyName(child) then
+ callback(child, mode)
+ end
end
elseif src.type == 'setglobal' then
- --if guide.getKeyName(src.parent) == key then
- -- callback(src.parent, 'set')
- --end
+ local parent = src.parent
+ child, mode = self:childMode(parent)
+ if child then
+ if key == guide.getKeyName(child) then
+ callback(child, mode)
+ end
+ end
else
self:eachField(src, key, callback)
end