blob: 86fd193ad1d80619ce7f004d13713f0a17193ba1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
---@class vm.node.generic
---@field parent vm.node.generic-manager
---@field node vm.node
local mt = {}
mt.__index = mt
mt.type = 'generic'
---@param node vm.node
---@param resolved table<string, vm.node>
---@return vm.node
local function cloneObject(node, resolved)
if node.type == 'doc.generic.name' then
local key = node[1]
return resolved[key]
end
return nil
end
---@param argNodes vm.node[]
---@return parser.object
function mt:resolve(argNodes)
local resolved = self.parent:resolve(argNodes)
local newProto = cloneObject(self.node, resolved)
return newProto
end
---@param parent vm.node.generic-manager
---@param node vm.node
return function (parent, node)
local generic = setmetatable({
parent = parent,
node = node,
}, mt)
return generic
end
|