TopchetoEU/revert-ES5 #31
@ -14,6 +14,7 @@ public class FunctionScope extends Scope {
|
||||
private final HashSet<String> blacklistNames = new HashSet<>();
|
||||
|
||||
private final HashMap<Variable, Variable> childToParent = new HashMap<>();
|
||||
private final HashMap<Variable, Variable> parentToChild = new HashMap<>();
|
||||
|
||||
private final Scope captureParent;
|
||||
|
||||
@ -63,11 +64,13 @@ public class FunctionScope extends Scope {
|
||||
var childVar = captures.add(parentVar.clone());
|
||||
capturesMap.put(childVar.name, childVar);
|
||||
childToParent.put(childVar, parentVar);
|
||||
parentToChild.put(parentVar, childVar);
|
||||
|
||||
return childVar;
|
||||
}
|
||||
|
||||
@Override public Variable get(Variable var, boolean capture) {
|
||||
if (parentToChild.containsKey(var)) return addCaptured(parentToChild.get(var), capture);
|
||||
if (captures.has(var)) return addCaptured(var, capture);
|
||||
if (locals.has(var)) return addCaptured(var, capture);
|
||||
|
||||
@ -78,6 +81,7 @@ public class FunctionScope extends Scope {
|
||||
|
||||
var childVar = captures.add(parentVar.clone());
|
||||
childToParent.put(childVar, parentVar);
|
||||
parentToChild.put(parentVar, childVar);
|
||||
|
||||
return childVar;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class Scope {
|
||||
|
||||
protected void transferCaptured(Variable var) {
|
||||
if (!singleEntry) {
|
||||
this.capturables.add(var);
|
||||
if (!this.capturables.has(var)) this.capturables.add(var);
|
||||
}
|
||||
else if (parent != null) {
|
||||
parent.transferCaptured(var);
|
||||
|
Loading…
Reference in New Issue
Block a user