diff --git a/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java b/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java
index 3dd4d74..f3b2f3a 100644
--- a/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java
+++ b/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java
@@ -101,6 +101,7 @@ import triangle.abstractSyntaxTrees.vnames.SimpleVname;
import triangle.abstractSyntaxTrees.vnames.SubscriptVname;
import triangle.abstractSyntaxTrees.vnames.Vname;
import triangle.codeGenerator.entities.AddressableEntity;
+import triangle.codeGenerator.entities.BarPrimitiveRoutine;
import triangle.codeGenerator.entities.EqualityRoutine;
import triangle.codeGenerator.entities.FetchableEntity;
import triangle.codeGenerator.entities.Field;
@@ -184,6 +185,11 @@ public final class Encoder implements ActualParameterVisitor,
@Override
public Void visitRepeatCommand(RepeatCommand ast, Frame frame) {
+ var loopAddr = emitter.getNextInstrAddr();
+ ast.C.visit(this, frame);
+ ast.E.visit(this, frame);
+ emitter.emit(OpCode.JUMPIF, Machine.falseRep, Register.CB, loopAddr);
+
return null;
}
@@ -740,6 +746,7 @@ public final class Encoder implements ActualParameterVisitor,
elaborateStdPrimRoutine(StdEnvironment.puteolDecl, Primitive.PUTEOL);
elaborateStdEqRoutine(StdEnvironment.equalDecl, Primitive.EQ);
elaborateStdEqRoutine(StdEnvironment.unequalDecl, Primitive.NE);
+ StdEnvironment.barDecl.entity = new BarPrimitiveRoutine(); //bardemo.tri now works
}
boolean tableDetailsReqd;
diff --git a/Triangle.Compiler/src/main/java/triangle/codeGenerator/entities/BarPrimitiveRoutine.java b/Triangle.Compiler/src/main/java/triangle/codeGenerator/entities/BarPrimitiveRoutine.java
new file mode 100644
index 0000000..101fccd
--- /dev/null
+++ b/Triangle.Compiler/src/main/java/triangle/codeGenerator/entities/BarPrimitiveRoutine.java
@@ -0,0 +1,27 @@
+package triangle.codeGenerator.entities;
+
+import triangle.abstractMachine.Machine;
+import triangle.abstractMachine.OpCode;
+import triangle.abstractMachine.Primitive;
+import triangle.abstractMachine.Register;
+import triangle.codeGenerator.Emitter;
+import triangle.codeGenerator.Frame;
+
+public class BarPrimitiveRoutine extends RuntimeEntity implements RoutineEntity {
+
+ public BarPrimitiveRoutine() {
+ super(Machine.closureSize);
+ }
+
+ public void encodeCall(Emitter emitter, Frame frame) {
+ //machine code to load 100 onto the stack
+ emitter.emit(OpCode.LOADL, 0, 100);
+ emitter.emit(OpCode.CALL, Register.PB, Primitive.MULT);
+ }
+
+ public void encodeFetch(Emitter emitter, Frame frame) {
+ emitter.emit(OpCode.LOADA, 0, Register.SB, 0);
+ emitter.emit(OpCode.LOADA, Register.PB, Primitive.MULT);
+ }
+
+}
diff --git a/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java b/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
index 188a632..e244217 100644
--- a/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
+++ b/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
@@ -188,6 +188,11 @@ public final class Checker implements ActualParameterVisitor