LEFT | RIGHT |
1 // This is a simple test to test global magic | |
2 | |
3 include("../utils/cleanast.js"); | |
4 include("../utils/dumpast.js"); | |
5 include("../utils/jstypes.js"); | |
6 | |
7 function process_js(ast, f) { | |
8 function loc(l) { | |
9 return f + ":" + l.line + ":" + l.column; | |
10 } | |
11 let toplevel = clean_ast(ast); | |
12 _print("Global variables:"); | |
13 for (let v of toplevel.variables) { | |
14 _print("\t" + v.name + " at " + f + ":" + v.loc.line + ":" + v.loc.column); | |
15 } | |
16 _print("Global constants:"); | |
17 for (let v of toplevel.constants) { | |
18 _print("\t" + v.name + " at " + f + ":" + v.loc.line + ":" + v.loc.column); | |
19 } | |
20 _print("Global objects:"); | |
21 for (let v of toplevel.objects) { | |
22 divine_inheritance(v, toplevel.constants); | |
23 _print("\t" + v.name + " at " + f + ":" + v.loc.line + ":" + v.loc.column); | |
24 if (v.inherits) { | |
25 _print("\tInherits from " + v.inherits.join(", ")); | |
26 } | |
27 _print("\tFunctions:"); | |
28 for (let name in v.functions) { | |
29 _print("\t\t" + name + " at " + loc(v.functions[name].loc)); | |
30 } | |
31 _print("\tVariables:"); | |
32 for (let name in v.variables) { | |
33 _print("\t\t" + name + " at " + loc(v.variables[name].loc)); | |
34 } | |
35 _print("\tGetters:"); | |
36 for (let name in v.getters) { | |
37 _print("\t\t" + name + " at " + loc(v.getters[name].loc)); | |
38 } | |
39 _print("\tSetters:"); | |
40 for (let name in v.setters) { | |
41 _print("\t\t" + name + " at " + loc(v.setters[name].loc)); | |
42 } | |
43 } | |
44 _print("Global classes:"); | |
45 for (let v of toplevel.classes) { | |
46 divine_inheritance(v, toplevel.constants); | |
47 _print("\t" + v.name + " at " + f + ":" + v.loc.line + ":" + v.loc.column); | |
48 if (v.inherits) { | |
49 _print("\tInherits from " + v.inherits.join(", ")); | |
50 } | |
51 _print("\tFunctions:"); | |
52 for (let name in v.functions) { | |
53 _print("\t\t" + name + " at " + loc(v.functions[name].loc)); | |
54 } | |
55 _print("\tVariables:"); | |
56 for (let name in v.variables) { | |
57 _print("\t\t" + name + " at " + loc(v.variables[name].loc)); | |
58 } | |
59 _print("\tGetters:"); | |
60 for (let name in v.getters) { | |
61 _print("\t\t" + name + " at " + loc(v.getters[name].loc)); | |
62 } | |
63 _print("\tSetters:"); | |
64 for (let name in v.setters) { | |
65 _print("\t\t" + name + " at " + loc(v.setters[name].loc)); | |
66 } | |
67 } | |
68 _print("Global functions:"); | |
69 for (let v of toplevel.functions) { | |
70 _print("\t" + v.name + " at " + f + ":" + v.loc.line + ":" + v.loc.column); | |
71 } | |
72 } | |
LEFT | RIGHT |