summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/core/engineer.lua10
-rw-r--r--server-beta/src/core/getfield.lua41
-rw-r--r--server-beta/src/core/getglobal.lua48
-rw-r--r--server-beta/src/core/getindex.lua48
-rw-r--r--server-beta/src/core/getmethod.lua48
-rw-r--r--server-beta/src/core/setfield.lua56
-rw-r--r--server-beta/src/core/setindex.lua48
-rw-r--r--server-beta/src/core/setmethod.lua54
8 files changed, 53 insertions, 300 deletions
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua
index 0553df9c..7bde9e4e 100644
--- a/server-beta/src/core/engineer.lua
+++ b/server-beta/src/core/engineer.lua
@@ -17,12 +17,12 @@ mt['setlocal'] = mt['getlocal']
mt['getglobal'] = require 'core.getglobal'
mt['setglobal'] = mt['getglobal']
mt['getfield'] = require 'core.getfield'
-mt['setfield'] = require 'core.setfield'
+mt['setfield'] = mt['getfield']
mt['tablefield'] = require 'core.tablefield'
-mt['getmethod'] = require 'core.getmethod'
-mt['setmethod'] = require 'core.setmethod'
-mt['getindex'] = require 'core.getindex'
-mt['setindex'] = require 'core.setindex'
+mt['getmethod'] = mt['getfield']
+mt['setmethod'] = mt['getfield']
+mt['getindex'] = mt['getfield']
+mt['setindex'] = mt['getfield']
mt['field'] = require 'core.field'
mt['method'] = require 'core.method'
mt['index'] = require 'core.index'
diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua
index 03aa7854..60d3d8d4 100644
--- a/server-beta/src/core/getfield.lua
+++ b/server-beta/src/core/getfield.lua
@@ -9,28 +9,27 @@ function m:field(source, key, callback)
used[source] = true
local node = source.node
- self:eachDef(node, function (src)
- used[src] = true
- end)
+ local myKey = guide.getKeyName(node)
- local myKey = guide.getKeyName(source)
- if key == myKey then
- callback(source, 'get')
+ if myKey == key then
+ callback(source)
end
- self:eachField(node, myKey, function (src, mode)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
+ self:eachDef(node, function (src)
+ if myKey ~= key then
+ return
+ end
+ used[src] = true
+ if node.type == 'setfield'
+ or node.type == 'setindex'
+ or node.type == 'setmethod' then
+ callback(src, 'set')
+ elseif node.type == 'getfield'
+ or node.type == 'getindex'
+ or node.type == 'getmethod' then
+ callback(src, 'get')
+ end
end)
-
self:eachValue(node, function (src)
self:eachField(src, key, function (src, mode)
if used[src] then
@@ -47,4 +46,10 @@ function m:field(source, key, callback)
checkSMT(self, key, used, found, callback)
end
+function m:value(source, callback)
+ if source.value then
+ self:eachValue(source.value, callback)
+ end
+end
+
return m
diff --git a/server-beta/src/core/getglobal.lua b/server-beta/src/core/getglobal.lua
index 72d208a5..4b4f4a10 100644
--- a/server-beta/src/core/getglobal.lua
+++ b/server-beta/src/core/getglobal.lua
@@ -66,38 +66,38 @@ function m:field(source, key, callback)
local found = false
used[source] = true
- local parent = source.parent
- self:eachField(parent, key, callback)
-
local node = source.node
- local myKey = guide.getKeyName(source)
- self:eachField(node, myKey, function (src, mode)
- if used[src] then
+ local myKey = guide.getKeyName(node)
+
+ if myKey == key then
+ callback(source)
+ end
+
+ self:eachDef(node, function (src)
+ if myKey ~= key then
return
end
used[src] = true
- self:eachField(src, key, function (src, mode)
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
+ if node.type == 'setfield'
+ or node.type == 'setindex'
+ or node.type == 'setmethod' then
+ callback(src, 'set')
+ elseif node.type == 'getfield'
+ or node.type == 'getindex'
+ or node.type == 'getmethod' then
+ callback(src, 'get')
+ end
end)
-
self:eachValue(node, function (src)
- self:eachField(src, myKey, function (src, mode)
+ self:eachField(src, key, function (src, mode)
if used[src] then
return
end
used[src] = true
- self:eachField(src, key, function (src, mode)
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
+ if mode == 'set' then
+ callback(src, mode)
+ found = true
+ end
end)
end)
@@ -105,7 +105,9 @@ function m:field(source, key, callback)
end
function m:value(source, callback)
- callback(source)
+ if source.value then
+ self:eachValue(source.value, callback)
+ end
end
return m
diff --git a/server-beta/src/core/getindex.lua b/server-beta/src/core/getindex.lua
deleted file mode 100644
index c0b3e517..00000000
--- a/server-beta/src/core/getindex.lua
+++ /dev/null
@@ -1,48 +0,0 @@
-local guide = require 'parser.guide'
-local checkSMT = require 'core.setmetatable'
-
-local m = {}
-
-function m:field(source, key, callback)
- local used = {}
- local found = false
- used[source] = true
-
- local node = source.node
- used[node] = true
-
- local myKey = guide.getKeyName(source)
- if key == myKey then
- callback(source, 'get')
- end
-
- self:eachField(node, myKey, function (src, mode)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- self:eachValue(node, function (src)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- checkSMT(self, key, used, found, callback)
-end
-
-return m
diff --git a/server-beta/src/core/getmethod.lua b/server-beta/src/core/getmethod.lua
deleted file mode 100644
index c0b3e517..00000000
--- a/server-beta/src/core/getmethod.lua
+++ /dev/null
@@ -1,48 +0,0 @@
-local guide = require 'parser.guide'
-local checkSMT = require 'core.setmetatable'
-
-local m = {}
-
-function m:field(source, key, callback)
- local used = {}
- local found = false
- used[source] = true
-
- local node = source.node
- used[node] = true
-
- local myKey = guide.getKeyName(source)
- if key == myKey then
- callback(source, 'get')
- end
-
- self:eachField(node, myKey, function (src, mode)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- self:eachValue(node, function (src)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- checkSMT(self, key, used, found, callback)
-end
-
-return m
diff --git a/server-beta/src/core/setfield.lua b/server-beta/src/core/setfield.lua
deleted file mode 100644
index 6f629d55..00000000
--- a/server-beta/src/core/setfield.lua
+++ /dev/null
@@ -1,56 +0,0 @@
-local guide = require 'parser.guide'
-local checkSMT = require 'core.setmetatable'
-
-local m = {}
-
-function m:field(source, key, callback)
- local used = {}
- local found = false
- used[source] = true
-
- local node = source.node
- self:eachDef(node, function (src)
- used[src] = true
- end)
-
- local myKey = guide.getKeyName(source)
- if key == myKey then
- callback(source, 'set')
- end
-
- self:eachField(node, myKey, function (src, mode)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- self:eachValue(node, function (src)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- checkSMT(self, key, used, found, callback)
-end
-
-function m:value(source, callback)
- if source.value then
- self:eachValue(source.value, callback)
- end
-end
-
-return m
diff --git a/server-beta/src/core/setindex.lua b/server-beta/src/core/setindex.lua
deleted file mode 100644
index 0c0913dc..00000000
--- a/server-beta/src/core/setindex.lua
+++ /dev/null
@@ -1,48 +0,0 @@
-local guide = require 'parser.guide'
-local checkSMT = require 'core.setmetatable'
-
-local m = {}
-
-function m:field(source, key, callback)
- local used = {}
- local found = false
- used[source] = true
-
- local node = source.node
- used[node] = true
-
- local myKey = guide.getKeyName(source)
- if key == myKey then
- callback(source, 'set')
- end
-
- self:eachField(node, myKey, function (src, mode)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- self:eachValue(node, function (src)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- checkSMT(self, key, used, found, callback)
-end
-
-return m
diff --git a/server-beta/src/core/setmethod.lua b/server-beta/src/core/setmethod.lua
deleted file mode 100644
index 881b5083..00000000
--- a/server-beta/src/core/setmethod.lua
+++ /dev/null
@@ -1,54 +0,0 @@
-local guide = require 'parser.guide'
-local checkSMT = require 'core.setmetatable'
-
-local m = {}
-
-function m:field(source, key, callback)
- local used = {}
- local found = false
- used[source] = true
-
- local node = source.node
- used[node] = true
-
- local myKey = guide.getKeyName(source)
- if key == myKey then
- callback(source, 'set')
- end
-
- self:eachField(node, myKey, function (src, mode)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- self:eachValue(node, function (src)
- self:eachField(src, key, function (src, mode)
- if used[src] then
- return
- end
- used[src] = true
- if mode == 'set' then
- callback(src, mode)
- found = true
- end
- end)
- end)
-
- checkSMT(self, key, used, found, callback)
-end
-
-function m:value(source, callback)
- if source.value then
- self:eachValue(source.value, callback)
- end
-end
-
-return m