This commit is contained in:
TopchetoEU 2023-09-09 18:12:24 +03:00
parent 8fb01e1091
commit fea17d944b
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
3 changed files with 2 additions and 13 deletions

View File

@ -66,9 +66,6 @@ public class SwitchStatement extends Statement {
if (instr.type == Type.NOP && instr.is(0, "break") && instr.get(1) == null) { if (instr.type == Type.NOP && instr.is(0, "break") && instr.get(1) == null) {
target.set(i, Instruction.jmp(target.size() - i).locate(instr.location)); target.set(i, Instruction.jmp(target.size() - i).locate(instr.location));
} }
if (instr.type == Type.NOP && instr.is(0, "try_break") && instr.get(1) == null) {
target.set(i, Instruction.signal("jmp_" + (target.size() - (Integer)instr.get(2))).locate(instr.location));
}
} }
for (var el : caseMap.entrySet()) { for (var el : caseMap.entrySet()) {
var loc = target.get(el.getKey()).location; var loc = target.get(el.getKey()).location;

View File

@ -81,14 +81,6 @@ public class WhileStatement extends Statement {
target.set(i, Instruction.jmp(breakPoint - i)); target.set(i, Instruction.jmp(breakPoint - i));
target.get(i).location = instr.location; target.get(i).location = instr.location;
} }
if (instr.type == Type.NOP && instr.is(0, "try_cont") && (instr.get(1) == null || instr.is(1, label))) {
target.set(i, Instruction.signal("jmp_" + (continuePoint - (Integer)instr.get(2))));
target.get(i).location = instr.location;
}
if (instr.type == Type.NOP && instr.is(0, "try_break") && (instr.get(1) == null || instr.is(1, label))) {
target.set(i, Instruction.signal("jmp_" + (breakPoint - (Integer)instr.get(2))));
target.get(i).location = instr.location;
}
} }
} }

View File

@ -28,10 +28,10 @@ public class FunctionStatement extends Statement {
public static void checkBreakAndCont(List<Instruction> target, int start) { public static void checkBreakAndCont(List<Instruction> target, int start) {
for (int i = start; i < target.size(); i++) { for (int i = start; i < target.size(); i++) {
if (target.get(i).type == Type.NOP) { if (target.get(i).type == Type.NOP) {
if (target.get(i).is(0, "break") || target.get(i).is(0, "try_break")) { if (target.get(i).is(0, "break") ) {
throw new SyntaxException(target.get(i).location, "Break was placed outside a loop."); throw new SyntaxException(target.get(i).location, "Break was placed outside a loop.");
} }
if (target.get(i).is(0, "cont") || target.get(i).is(0, "try_cont")) { if (target.get(i).is(0, "cont")) {
throw new SyntaxException(target.get(i).location, "Continue was placed outside a loop."); throw new SyntaxException(target.get(i).location, "Continue was placed outside a loop.");
} }
} }