summaryrefslogtreecommitdiff
path: root/script/vm/node.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-24 05:05:39 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-24 05:05:39 +0800
commitafbe46c3090e55ff08302b5306ce6dae99f09c54 (patch)
tree250d17bd9c841fc8ceb78de58637c7f555482471 /script/vm/node.lua
parente76e59948ff86f37a7b17fa79ca7041a1dae1bf8 (diff)
downloadlua-language-server-afbe46c3090e55ff08302b5306ce6dae99f09c54.zip
infer by `if not x or x.y then`
Diffstat (limited to 'script/vm/node.lua')
-rw-r--r--script/vm/node.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 204a149d..d3e407b6 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -10,6 +10,7 @@ vm.nodeCache = {}
---@field [integer] vm.object
local mt = {}
mt.__index = mt
+mt.id = 0
mt.type = 'vm.node'
mt.optional = nil
mt.lastInfer = nil
@@ -273,11 +274,16 @@ function vm.clearNodeCache()
vm.nodeCache = {}
end
+local ID = 0
+
---@param a? vm.node | vm.object
---@param b? vm.node | vm.object
---@return vm.node
function vm.createNode(a, b)
- local node = setmetatable({}, mt)
+ ID = ID + 1
+ local node = setmetatable({
+ id = ID,
+ }, mt)
if a then
node:merge(a)
end