repeatuntil works

java11
simonkellet 2 years ago
parent c9ca3c5bba
commit 693d933c19
  1. 4
      Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java
  2. 4
      Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
  3. BIN
      build/libs/Triangle-Tools.jar

@ -185,6 +185,10 @@ public final class Encoder implements ActualParameterVisitor<Frame, Integer>,
@Override @Override
public Void visitRepeatCommand(RepeatCommand ast, Frame frame) { public Void visitRepeatCommand(RepeatCommand ast, Frame frame) {
var loopAddr = emitter.getNextInstrAddr();
ast.E.visit(this, frame);
ast.C.visit(this, frame);
emitter.emit(OpCode.JUMPIF, Machine.trueRep, Register.CB, loopAddr);
return null; return null;
} }

@ -188,6 +188,10 @@ public final class Checker implements ActualParameterVisitor<FormalParameter, Vo
@Override @Override
public Void visitRepeatCommand(RepeatCommand ast, Void arg) { public Void visitRepeatCommand(RepeatCommand ast, Void arg) {
var eType = ast.E.visit(this);
checkAndReportError(eType.equals(StdEnvironment.booleanType), "Boolean expression expected here", ast.E);
ast.C.visit(this);
return null; return null;
} }

Binary file not shown.