Create environments #4
@ -66,9 +66,6 @@ public class SwitchStatement extends Statement {
|
||||
if (instr.type == Type.NOP && instr.is(0, "break") && instr.get(1) == null) {
|
||||
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()) {
|
||||
var loc = target.get(el.getKey()).location;
|
||||
|
@ -81,14 +81,6 @@ public class WhileStatement extends Statement {
|
||||
target.set(i, Instruction.jmp(breakPoint - i));
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,10 @@ public class FunctionStatement extends Statement {
|
||||
public static void checkBreakAndCont(List<Instruction> target, int start) {
|
||||
for (int i = start; i < target.size(); i++) {
|
||||
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.");
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user