From 8e530c9973e55f91569051008eb1c330595dc40d Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 12 Feb 2008 10:15:00 +0100 Subject: [PATCH] cleanup obsolete stuff --- src/edu/berkeley/fleet/api/Instruction.java | 1 - .../fleet/interpreter/InstructionPump.java | 27 +++++--------------- .../berkeley/fleet/interpreter/Interpreter.java | 2 +- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/edu/berkeley/fleet/api/Instruction.java b/src/edu/berkeley/fleet/api/Instruction.java index af9e9ce..81af0df 100644 --- a/src/edu/berkeley/fleet/api/Instruction.java +++ b/src/edu/berkeley/fleet/api/Instruction.java @@ -8,7 +8,6 @@ public abstract class Instruction { public boolean isLooping() { return true; } public boolean isRepeating() { return false; } - public boolean isStanding() { return false; } public boolean isSK() { return false; } public boolean isDL() { return false; } diff --git a/src/edu/berkeley/fleet/interpreter/InstructionPump.java b/src/edu/berkeley/fleet/interpreter/InstructionPump.java index 941662c..7058ae4 100644 --- a/src/edu/berkeley/fleet/interpreter/InstructionPump.java +++ b/src/edu/berkeley/fleet/interpreter/InstructionPump.java @@ -20,9 +20,6 @@ abstract class InstructionPump extends InterpreterPump { /** all instructions waiting to be executed (excludes executing) */ private Queue instructions = new LinkedList(); - /** count of how many "standing instruction only" kills remain to be executed */ - private int killNextStandingInstruction = 0; - public int loopCounter = 0; private int repeatCounter = 1; @@ -38,27 +35,16 @@ abstract class InstructionPump extends InterpreterPump { 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; @@ -159,7 +145,6 @@ abstract class InstructionPump extends InterpreterPump { } else if (executing.isLooping() && oldLoopCounter > 0) { addInstruction(executing); executing = null; - } else if (executing.isStanding()) { } else { executing = null; } diff --git a/src/edu/berkeley/fleet/interpreter/Interpreter.java b/src/edu/berkeley/fleet/interpreter/Interpreter.java index b82ac4d..cc5650b 100644 --- a/src/edu/berkeley/fleet/interpreter/Interpreter.java +++ b/src/edu/berkeley/fleet/interpreter/Interpreter.java @@ -95,7 +95,7 @@ public class Interpreter extends Fleet implements Fleet.WithDynamicShips { } 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); -- 1.7.10.4