summaryrefslogtreecommitdiff
path: root/script/vm/node.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-23 16:56:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-23 16:56:13 +0800
commit5d46db21e707be3b23655ef7fc1dfc41c36464a2 (patch)
tree3fa78dac7b5c9c78341e70db937367a3d3a694f0 /script/vm/node.lua
parentca632b4bbc66eea45e9cd90dccd6b7f895cac018 (diff)
downloadlua-language-server-5d46db21e707be3b23655ef7fc1dfc41c36464a2.zip
update
Diffstat (limited to 'script/vm/node.lua')
-rw-r--r--script/vm/node.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 24f87a45..fce8c642 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -7,8 +7,10 @@ local guide = require 'parser.guide'
---@type table<vm.object, vm.node>
vm.nodeCache = {}
+---@alias vm.node.object vm.object | vm.global
+
---@class vm.node
----@field [integer] vm.object
+---@field [integer] vm.node.object
---@field [vm.object] true
local mt = {}
mt.__index = mt
@@ -17,7 +19,7 @@ mt.type = 'vm.node'
mt.optional = nil
mt.data = nil
----@param node vm.node | vm.object
+---@param node vm.node | vm.node.object
function mt:merge(node)
if not node then
return
@@ -319,7 +321,7 @@ function mt:hasName(name)
return false
end
----@return fun():vm.object
+---@return fun():vm.node.object
function mt:eachObject()
local i = 0
return function ()
@@ -334,7 +336,7 @@ function mt:copy()
end
---@param source vm.object
----@param node vm.node | vm.object
+---@param node vm.node | vm.node.object
---@param cover? boolean
---@return vm.node
function vm.setNode(source, node, cover)
@@ -345,9 +347,6 @@ function vm.setNode(source, node, cover)
log.error('Can not set nil node')
end
end
- if source.type == 'global' then
- error('Can not set node to global')
- end
if cover then
---@cast node vm.node
vm.nodeCache[source] = node
@@ -403,8 +402,8 @@ end
local ID = 0
----@param a? vm.node | vm.object
----@param b? vm.node | vm.object
+---@param a? vm.node | vm.node.object
+---@param b? vm.node | vm.node.object
---@return vm.node
function vm.createNode(a, b)
ID = ID + 1