/** all instructions waiting to be executed (excludes executing) */
private Queue<Instruction> instructions = new LinkedList<Instruction>();
- /** count of how many "standing instruction only" kills remain to be executed */
- private int killNextStandingInstruction = 0;
-
public int loopCounter = 0;
private int repeatCounter = 1;
instructions.remove();
}
- public void kill(int count, boolean killOnlyStandingInstructions) {
- if (count==0) return;
+ public void kill() {
repeatCounter = 1;
- if (!killOnlyStandingInstructions) {
- if (executing != null) { executing = null; count--; }
- for(;count > 0;count--) {
- if (instructions.size()==0)
- throw new RuntimeException("deadlocked " + this + " by killing too many instructions");
- instructions.remove();
- }
- } else {
- if (count != 1) throw new RuntimeException("this should never happen");
- this.killNextStandingInstruction++;
- }
+ if (executing != null) { executing = null; return; }
+ if (instructions.size()==0)
+ throw new RuntimeException("deadlocked " + this + " by killing too many instructions");
+ instructions.remove();
}
/** an instruction arrives from the instruction horn */
- void addInstruction(Instruction instr) {
- if (killNextStandingInstruction > 0) { /* FIXME technically we should refuse to take the next instruction here */ }
- instructions.add(instr);
- }
+ void addInstruction(Instruction instr) { instructions.add(instr); }
protected void shutdown(boolean leaveAsInbox) {
if (!(executing != null || instructions.size() > 0)) return;
} else if (executing.isLooping() && oldLoopCounter > 0) {
addInstruction(executing);
executing = null;
- } else if (executing.isStanding()) {
} else {
executing = null;
}
} else if (i instanceof Instruction.Kill) {
InterpreterPump pump = (InterpreterPump)(((Instruction.Kill)i).pump);
- ((InstructionPump)pump).kill(((Instruction.Kill)i).count+1, false);
+ ((InstructionPump)pump).kill();
} else if (i instanceof Instruction.Massacre) {
InterpreterPump pump = (InterpreterPump)(((Instruction.Massacre)i).pump);