summaryrefslogtreecommitdiff
path: root/test/basic/linker.txt
blob: ea3ba180db43a0b5d18ebcaa5da89b642b751943 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
ast -> linkers = {
    ['g|"X"|"Y"|"Z"'] = {src1, src2, src3},
    ['g|"X"|"Y"']     = {src4, src5, src6},
    ['g|"X"']         = {src7, src8, src9},
    ['l|7']           = {src10},
    ['l|7|"x"']       = {src11},
    ['l|11|"k"']      = {src12},
}

```lua
x.y.<?z?> = <!f!>

<?g?> = x.y.z

t.<!z!> = 1
x.y = t

x = {
    y = {
        <!z!> = 1
    }
}
```

expect:   'l|x|y|z'
forward:  'l|x|y|z' -> f
backward: 'l|x|y|z' -> g
last:     'l|x|y' + 'z'

expect:   'l|x|y' + '|z'
forward:  'l|t' + '|z' -> 'l|t|z' -> t.z
backward: nil
last:     'l|x' + '|y|z'

expect:   'l|x' + '|y|z'
forward:  'l|0' + '|y|z' -> 'l|0|y|z'
backward: nil
last:     nil

expect:   'l|0|y|z'
forward:  nil
backward: nil
last:     'l|0|y' + '|z'

expect:   'l|0|y' + '|z'
forward:  'l|1'+ '|z' -> 'l|1|z' -> field z
backward: nil
last:     'l|0' + '|y|z'


```lua
a = {
    b = {
        <?c?> = 1,
    }
}

print(a.b.<!c!>)
```

expect:   't|3|c'
forward:  nil
backward: nil
last:     't|3' + '|c'

expect:   't|3' + '|c'
forward:  nil
backward: 't|2|b' + '|c'
last:     nil

expect:   't|2|b|c'
forward:  nil
backward: 't|2|b' + '|c'
last:     nil

```lua
---@return <?A?>
local function f()
end

local <!x!> = f()
```

'd|A'
'f|1|#1'
'f|1' + '|#1'
'l|1' + '|#1'
's|1' + '|#1'

```lua
---@generic T
---@param a T
---@return T
local function f(a) end

local <?c?>

local <!v!> = f(c)
```

'l1'
'l2|@1'
'f|1|@1'
'f|1|#1'

```
---@generic T
---@param p T
---@return T
local function f(p) end

local <?r?> = f(<!k!>)
```

l:r
s:1#1 call
l:f#1 call
f:1#1 call -> f:1&T = l:k
l:f@1 --> 从保存的call信息里找到 f:1&T = l:k
l:k



```
---@generic T, V
---@param p T
---@return fun(V):T, V
local function f(p) end

local f2 = f(<!k!>)
local <?r?> = f2()
```

l:r
s:2|#1 call1
l:f2|#1 call1
f:2|#1 call1
s:1#1|#1 call2
f:1#1|#1 call2 -> f:1&T = l:k
dfun:1|#1
dn:V -> f:1&T = l:k