summaryrefslogtreecommitdiff
path: root/script/vm/node.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/vm/node.lua')
-rw-r--r--script/vm/node.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 8ed5c027..65a203f8 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -81,6 +81,7 @@ end
function mt:removeOptional()
self:remove 'nil'
+ return self
end
---@return boolean
@@ -293,6 +294,24 @@ function mt:hasType(name)
return false
end
+---@param name string
+---@return boolean
+function mt:hasName(name)
+ if name == 'nil' and self.optional == true then
+ return true
+ end
+ for _, c in ipairs(self) do
+ if c.type == 'global' and c.cate == 'type' and c.name == name then
+ return true
+ end
+ if c.type == name then
+ return true
+ end
+ -- TODO
+ end
+ return false
+end
+
---@return fun():vm.object
function mt:eachObject()
local i = 0