fix: try-catch broken (again)
This commit is contained in:
parent
66440a9649
commit
6fac295b99
@ -53,9 +53,11 @@ public class TryNode extends Node {
|
|||||||
|
|
||||||
if (captureName != null) {
|
if (captureName != null) {
|
||||||
var catchVar = target.catchBindings.get(this);
|
var catchVar = target.catchBindings.get(this);
|
||||||
|
target.scope.defineCatch(captureName, catchVar);
|
||||||
target.add(Instruction.loadError()).setLocation(catchBody.loc());
|
target.add(Instruction.loadError()).setLocation(catchBody.loc());
|
||||||
target.add(catchVar.index().toSet(false)).setLocation(catchBody.loc());
|
target.add(catchVar.index().toSet(false)).setLocation(catchBody.loc());
|
||||||
catchBody.compile(target, false);
|
catchBody.compile(target, false);
|
||||||
|
target.scope.undefineCatch();
|
||||||
}
|
}
|
||||||
else catchBody.compile(target, false);
|
else catchBody.compile(target, false);
|
||||||
|
|
||||||
@ -65,6 +67,7 @@ public class TryNode extends Node {
|
|||||||
if (finallyBody != null) {
|
if (finallyBody != null) {
|
||||||
finallyStart = target.size() - start;
|
finallyStart = target.size() - start;
|
||||||
finallyBody.compile(target, false);
|
finallyBody.compile(target, false);
|
||||||
|
target.add(Instruction.tryEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelContext.getBreak(target.env).pop(label);
|
LabelContext.getBreak(target.env).pop(label);
|
||||||
|
@ -63,6 +63,15 @@ public final class FunctionScope {
|
|||||||
this.catchesMap.add(var);
|
this.catchesMap.add(var);
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Creates a catch variable, using a specific variable instance
|
||||||
|
* Used in the second pass
|
||||||
|
*/
|
||||||
|
public Variable defineCatch(String name, Variable var) {
|
||||||
|
this.locals.add(var);
|
||||||
|
this.catchesMap.add(var);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Removes the last catch variable.
|
* Removes the last catch variable.
|
||||||
* NOTE: the variable is still in the internal list. It just won't be findable by its name
|
* NOTE: the variable is still in the internal list. It just won't be findable by its name
|
||||||
|
Loading…
Reference in New Issue
Block a user