summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/node.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 87fcc0c5..92604c3c 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -7,6 +7,7 @@ local ws = require 'workspace.workspace'
vm.nodeCache = {}
---@class vm.node
+---@field [integer] vm.object
local mt = {}
mt.__index = mt
mt.type = 'vm.node'
@@ -85,6 +86,7 @@ function mt:isFalsy()
end
for _, c in ipairs(self) do
if c.type == 'nil'
+ or (c.type == 'global' and c.cate == 'type' and c.name == 'nil')
or (c.type == 'boolean' and c[1] == false)
or (c.type == 'doc.type.boolean' and c[1] == false) then
return true
@@ -93,6 +95,20 @@ function mt:isFalsy()
return false
end
+---@return boolean
+function mt:isNullable()
+ if self.optional then
+ return true
+ end
+ for _, c in ipairs(self) do
+ if c.type == 'nil'
+ or (c.type == 'global' and c.cate == 'type' and c.name == 'nil') then
+ return true
+ end
+ end
+ return false
+end
+
---@return vm.node
function mt:copyTruly()
local newNode = vm.createNode()