JS: when resolving temporary functions, don't rely on JsScope hierarchy, build this hierarchy instead, based on scoping rules for function, var, etc expressions
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
var x_0 = 23;
|
||||
var x_1 = 42;
|
||||
|
||||
function foo() {
|
||||
println(x_0);
|
||||
}
|
||||
|
||||
function bar() {
|
||||
println(x + x_1);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
var $a = 23;
|
||||
var $b = 42;
|
||||
|
||||
function foo() {
|
||||
println($a);
|
||||
}
|
||||
|
||||
function bar() {
|
||||
println(x + $b);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
function foo() {
|
||||
x: {
|
||||
x_0: {
|
||||
console.log("1");
|
||||
console.log(function() {
|
||||
x: {
|
||||
console.log("2");
|
||||
}
|
||||
});
|
||||
|
||||
if (condition()) {
|
||||
break x;
|
||||
}
|
||||
else {
|
||||
break x_0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x: {
|
||||
x_0: {
|
||||
console.log("1");
|
||||
}
|
||||
x_0: {
|
||||
console.log("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
function foo() {
|
||||
$a: {
|
||||
$b: {
|
||||
console.log("1");
|
||||
console.log(function() {
|
||||
$aa: {
|
||||
console.log("2");
|
||||
}
|
||||
});
|
||||
|
||||
if (condition()) {
|
||||
break $a;
|
||||
}
|
||||
else {
|
||||
break $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$c: {
|
||||
$d: {
|
||||
console.log("1");
|
||||
}
|
||||
$e: {
|
||||
console.log("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
var x = 23;
|
||||
var x_0 = 42;
|
||||
|
||||
function foo() {
|
||||
var x_0 = 99;
|
||||
console.log(x + x_0);
|
||||
}
|
||||
|
||||
function bar() {
|
||||
var x = 101;
|
||||
console.log(x_0 + x);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
var $a = 23;
|
||||
var $b = 42;
|
||||
|
||||
function foo() {
|
||||
var $c = 99;
|
||||
console.log($a + $c);
|
||||
}
|
||||
|
||||
function bar() {
|
||||
var $d = 101;
|
||||
console.log($b + $d);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
var x = 23;
|
||||
|
||||
function x_0() {
|
||||
var x_0 = 42;
|
||||
var x_1 = 99;
|
||||
return x + x_0 + x_1;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
var $a = 23;
|
||||
|
||||
function $f() {
|
||||
var $b = 42;
|
||||
var $c = 99;
|
||||
return $a + $b + $c;
|
||||
}
|
||||
Reference in New Issue
Block a user