summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/compiler.lua28
-rw-r--r--script/vm/local-id.lua5
2 files changed, 32 insertions, 1 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index aad5a836..5a6862c9 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -46,6 +46,34 @@ local searchFieldMap = util.switch()
end
end
end)
+ : case 'doc.type.array'
+ : call(function (node, key, pushResult)
+ if type(key) == 'number'
+ and math.tointeger(key)
+ and key >= 1 then
+ pushResult(node.node)
+ end
+ end)
+ : case 'doc.type.table'
+ : call(function (node, key, pushResult)
+ for _, field in ipairs(node.fields) do
+ local fieldKey = field.name
+ if fieldKey.type == 'doc.type' then
+ local fieldNode = m.compileNode(fieldKey)
+ for fn in nodeMgr.eachNode(fieldNode) do
+ if fn.type == 'global' and fn.cate == 'type' then
+ if fn.name == 'any'
+ or (fn.name == 'boolean' and type(key) == 'boolean')
+ or (fn.name == 'number' and type(key) == 'number')
+ or (fn.name == 'integer' and math.tointeger(key))
+ or (fn.name == 'string' and type(key) == 'string') then
+ pushResult(field.extends)
+ end
+ end
+ end
+ end
+ end
+ end)
: getMap()
diff --git a/script/vm/local-id.lua b/script/vm/local-id.lua
index 230f48eb..3b266916 100644
--- a/script/vm/local-id.lua
+++ b/script/vm/local-id.lua
@@ -60,7 +60,7 @@ local compileMap = util.switch()
return
end
local key = guide.getKeyName(source)
- if not key then
+ if not type(key) ~= 'string' then
return
end
source._localID = parentID .. m.ID_SPLITE .. key
@@ -152,6 +152,9 @@ function m.getSources(source, key)
return nil
end
if key then
+ if type(key) ~= 'string' then
+ return nil
+ end
id = id .. m.ID_SPLITE .. key
end
return root._localIDs[id]