blob: 51cfe1ac76cf823b2a7046111aa0b08afaaf340b (
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
|
local collector = require 'core.collector'
local vm = require 'vm.vm'
function vm.hasGlobalSets(name)
local id = ('def:g:%q'):format(name)
return collector.has(id)
end
function vm.getGlobalSets(name)
local cache = vm.getCache 'getGlobalSets'
if cache[name] then
return cache[name]
end
local results = {}
cache[name] = results
local id
if name == '*' then
id = 'def:g:'
else
id = ('def:g:%q'):format(name)
end
for node in collector.each(id) do
if node.sources then
for _, source in ipairs(node.sources) do
results[#results+1] = source
end
end
end
return results
end
|