blob: 3c0c956407c656b1fcaa856b1da073f01681cbd1 (
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
36
37
38
39
40
41
|
return function (source)
local value = source:bindValue()
local func = value:getFunction()
local declarat
if func then
declarat = func.source.name
else
declarat = source
end
if not declarat then
return source:getName() or ''
end
local key
if declarat.type == 'name' then
key = declarat[1]
elseif declarat.type == 'string' then
key = ('%q'):format(declarat[1])
elseif declarat.type == 'number' or declarat.type == 'boolean' then
key = tostring(declarat[1])
elseif declarat.type == 'simple' then
local chars = {}
for i, obj in ipairs(declarat) do
if obj.type == 'name' then
chars[i] = obj[1]
elseif obj.type == 'index' then
chars[i] = '[?]'
elseif obj.type == 'call' then
chars[i] = '(?)'
elseif obj.type == ':' then
chars[i] = ':'
elseif obj.type == '.' then
chars[i] = '.'
end
end
key = table.concat(chars)
else
key = ''
end
return key
end
|