small fixes

This commit is contained in:
TopchetoEU 2023-08-25 14:32:13 +03:00
parent 0ea01996ee
commit 396d7ca5a2
No known key found for this signature in database
GPG Key ID: 24E57B2E9C61AD19
2 changed files with 4 additions and 2 deletions

View File

@ -27,9 +27,10 @@ public class TryStatement extends Statement {
@Override
public void compile(List<Instruction> target, ScopeRecord scope) {
target.add(Instruction.nop());
int start = target.size(), tryN, catchN = -1, finN = -1;
target.add(Instruction.nop());
tryBody.compileNoPollution(target, scope);
tryN = target.size() - start;
@ -60,7 +61,7 @@ public class TryStatement extends Statement {
// }
// }
target.set(start, Instruction.tryInstr(tryN, catchN, finN).locate(loc()));
target.set(start - 1, Instruction.tryInstr(tryN, catchN, finN).locate(loc()));
}
public TryStatement(Location loc, Statement tryBody, Statement catchBody, Statement finallyBody, String name) {

View File

@ -195,6 +195,7 @@ public class CodeFrame {
if (!jumpFlag) {
if (tmp.state == TryCtx.STATE_FINALLY_THREW) throw tmp.err;
else if (tmp.state == TryCtx.STATE_FINALLY_RETURNED) return tmp.retVal;
else if (tmp.state == TryCtx.STATE_FINALLY_JUMPED) codePtr = tmp.jumpPtr;
}
else codePtr = tmp.jumpPtr;
remove = true;