bardemo works
This commit is contained in:
parent
e1268aae42
commit
c9ca3c5bba
@ -16,6 +16,7 @@ public class RepeatCommand extends Command {
|
|||||||
return v.visitRepeatCommand(this, arg);
|
return v.visitRepeatCommand(this, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Expression E;
|
//public final Expression E;
|
||||||
|
public Expression E;
|
||||||
public final Command C;
|
public final Command C;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ import triangle.abstractSyntaxTrees.vnames.SimpleVname;
|
|||||||
import triangle.abstractSyntaxTrees.vnames.SubscriptVname;
|
import triangle.abstractSyntaxTrees.vnames.SubscriptVname;
|
||||||
import triangle.abstractSyntaxTrees.vnames.Vname;
|
import triangle.abstractSyntaxTrees.vnames.Vname;
|
||||||
import triangle.codeGenerator.entities.AddressableEntity;
|
import triangle.codeGenerator.entities.AddressableEntity;
|
||||||
|
import triangle.codeGenerator.entities.BarPrimitiveRoutine;
|
||||||
import triangle.codeGenerator.entities.EqualityRoutine;
|
import triangle.codeGenerator.entities.EqualityRoutine;
|
||||||
import triangle.codeGenerator.entities.FetchableEntity;
|
import triangle.codeGenerator.entities.FetchableEntity;
|
||||||
import triangle.codeGenerator.entities.Field;
|
import triangle.codeGenerator.entities.Field;
|
||||||
@ -740,6 +741,9 @@ public final class Encoder implements ActualParameterVisitor<Frame, Integer>,
|
|||||||
elaborateStdPrimRoutine(StdEnvironment.puteolDecl, Primitive.PUTEOL);
|
elaborateStdPrimRoutine(StdEnvironment.puteolDecl, Primitive.PUTEOL);
|
||||||
elaborateStdEqRoutine(StdEnvironment.equalDecl, Primitive.EQ);
|
elaborateStdEqRoutine(StdEnvironment.equalDecl, Primitive.EQ);
|
||||||
elaborateStdEqRoutine(StdEnvironment.unequalDecl, Primitive.NE);
|
elaborateStdEqRoutine(StdEnvironment.unequalDecl, Primitive.NE);
|
||||||
|
|
||||||
|
StdEnvironment.barDecl.entity = new BarPrimitiveRoutine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean tableDetailsReqd;
|
boolean tableDetailsReqd;
|
||||||
|
@ -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) {
|
||||||
|
//push the literal value of 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
@ -9,7 +9,12 @@ in
|
|||||||
b := 2;
|
b := 2;
|
||||||
|
|
||||||
putint(a);
|
putint(a);
|
||||||
|
puteol();
|
||||||
putint(b);
|
putint(b);
|
||||||
|
puteol();
|
||||||
putint(|a);
|
putint(|a);
|
||||||
putint(|b)
|
puteol();
|
||||||
|
putint(|b);
|
||||||
|
puteol()
|
||||||
|
|
||||||
end
|
end
|
Reference in New Issue
Block a user