summaryrefslogtreecommitdiff
path: root/script/vm/node.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-14 17:07:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-14 17:07:37 +0800
commit75a7cabcbc37b39a6932ddd13dc847c505077de7 (patch)
treea9cb344248fd944ef4539ab73e909182ad13bc1c /script/vm/node.lua
parentbae265094084e3b1887b92402de0cf2be14abb5d (diff)
downloadlua-language-server-75a7cabcbc37b39a6932ddd13dc847c505077de7.zip
stash
Diffstat (limited to 'script/vm/node.lua')
-rw-r--r--script/vm/node.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 1486ac47..b43bea3a 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -12,6 +12,7 @@ mt.__index = mt
mt.type = 'vm.node'
mt.optional = nil
mt.lastInfer = nil
+mt.data = nil
---@type vm.node[]
mt._childs = nil
mt._locked = false
@@ -130,6 +131,20 @@ function mt:isLocked()
return self._locked == true
end
+function mt:setData(k, v)
+ if not self.data then
+ self.data = {}
+ end
+ self.data[k] = v
+end
+
+function mt:getData(k)
+ if not self.data then
+ return nil
+ end
+ return self.data[k]
+end
+
function mt:addOptional()
if self:isOptional() then
return self
@@ -209,6 +224,11 @@ function vm.getNode(source)
return vm.nodeCache[source]
end
+---@param source vm.object
+function vm.removeNode(source)
+ vm.nodeCache[source] = nil
+end
+
function vm.clearNodeCache()
vm.nodeCache = {}
end