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
142
143
|
This testcase asserts that import/export symbols in runtime loaded code
are properly dealt with.
Since the compiler has no knowledge about runtime loaded code it cannot
reserve slots in the export table, requiring the VM to maintain one export
table per program instance.
The dependency tree is:
root
+ import: mod1
+ import: mod2
+ require: mod3
+ import: mod1
+ import: mod2
-- Testcase --
import { mod2sym1, mod2sym2 } from 'mod2';
import { mod1sym1, mod1sym2 } from 'mod1';
mod3 = require('mod3');
printf("root: %.J\n", { mod1sym1, mod1sym2, mod2sym1, mod2sym2, mod3 });
-- End --
-- File mod1.uc --
export const mod1sym1 = "a";
export const mod1sym2 = "b";
-- End --
-- File mod2.uc --
export const mod2sym1 = "c";
export const mod2sym2 = "d";
-- End --
-- File mod3.uc --
import { mod1sym2, mod1sym1 } from 'mod1';
import { mod2sym2, mod2sym1 } from 'mod2';
printf("mod3: %.J\n", { mod1sym1, mod1sym2, mod2sym1, mod2sym2 });
return { mod1sym1, mod1sym2, mod2sym1, mod2sym2 };
-- End --
-- Args --
-R -L files/
-- End --
-- Expect stdout --
mod3: {
"mod1sym1": "a",
"mod1sym2": "b",
"mod2sym1": "c",
"mod2sym2": "d"
}
root: {
"mod1sym1": "a",
"mod1sym2": "b",
"mod2sym1": "c",
"mod2sym2": "d",
"mod3": {
"mod1sym1": "a",
"mod1sym2": "b",
"mod2sym1": "c",
"mod2sym2": "d"
}
}
-- End --
A variation of the above testcase using wildcard imports.
root
+ import: mod4
+ import: mod5
+ require: mod6
+ import: mod4
+ import: mod5
-- Testcase --
import * as mod5 from 'mod5';
import * as mod4 from 'mod4';
mod6 = require('mod6');
printf("root: %.J\n", { mod4, mod5, mod6 });
-- End --
-- File mod4.uc --
export const sym1 = "a";
export const sym2 = "b";
-- End --
-- File mod5.uc --
export const sym1 = "c";
export const sym2 = "d";
-- End --
-- File mod6.uc --
import * as mod4 from 'mod4';
import * as mod5 from 'mod5';
printf("mod6: %.J\n", { mod4, mod5 });
return { mod4, mod5 };
-- End --
-- Args --
-R -L files/
-- End --
-- Expect stdout --
mod6: {
"mod4": {
"sym1": "a",
"sym2": "b"
},
"mod5": {
"sym1": "c",
"sym2": "d"
}
}
root: {
"mod4": {
"sym1": "a",
"sym2": "b"
},
"mod5": {
"sym1": "c",
"sym2": "d"
},
"mod6": {
"mod4": {
"sym1": "a",
"sym2": "b"
},
"mod5": {
"sym1": "c",
"sym2": "d"
}
}
}
-- End --
|