-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
107 lines (89 loc) · 1.92 KB
/
example.js
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
function funcA() {
var x;
function funcB() {
var y;
function funcC() {
if(42) {
let z;
function funcD() {
y = x;
function funcE() {
x = z;
}
}
}
}
}
}
/*aexpr ignre*/
var x = 5, z = 42;
glob3 = glob = 'foo';
(glob = 42).toString();
x = glob + 4;
glob2 = x + 3;
z = x;
z = xGlobal;
func(glob);
var Rectangle2 = class {
constructor(x, y, width, height) {
this["x"] = x;
this["y"] = y;
this["width"] = width;
this["height"] = height;
}
area() {
return this["width"] * this["height"];
}
}
var a = {b:1, fn() { return {}; }}
var c = {}
var y;
a.b += 15;
a.b = 15;
a.d **= i;
a.e = c.d;
a.b.c
y = z
// nested left side of assignment
a.b.c = y.z
// Mixin everything together
a.fn()[c.d] = 1
function xyz() {
return x.y.z;
}
var foo = {
bar: 42,
onChange() {}
}
var r1 = new Rectangle2(0, 0, 10, 20),
r2 = new Rectangle2(5, 10, 20, 30);
var axerp = function(...args) {
args[0]();
return args[1];
}
axerp(() => r1["area"](), foo)["onChange"](() => console["log"]('changed'));
var arr = [1,2,3];
arr[2]
console.log( foo == 2)
aexpr().onChange();
(function() {
function aexpr() {}
aexpr();
})();
/*
// currently not supported is the following scenario
var obj = {
x: 42,
fn: function() {
return this.x
}
}
function getter(o,p) { return o[p]; }
// when we have a CallExpression as parent of the MemberExpression, the this reference is bound implicitly
obj.fn() // 42
// also working fine
obj["fn"]() // 42
// however, with the current implementation we loose the this reference when wrapping just the inner MemberExpression
getter(obj, "fn")() // undefined
00> we did this by doing explicit checks on CallExpressions (with the callee being a MemberExpression)
*/