package AM.am_data_structure;
/**
* Created by IntelliJ IDEA. User: yellowicq Date: 2004-4-27 Time: 12:25:10
* To change this template use File | Settings | File Templates.
*/
import java.util.Vector;
import AM.vm_impl.util.Tracer;
public abstract class AbstractProgram implements Program {
public int CP;
private Vector program; // A container of AbstractInstruction
private InstructionSet instSet;
public AbstractProgram(InstructionSet instSet) {
this.instSet = instSet;
}
public void LoadProgram(Stream assemblerCode) {
// load instructions from the assembler code
program = instSet.resolve(assemblerCode);
if (program == null) {
throw new NullPointerException("Program load failed!");
}
Tracer.debug("Instruction in program[" + program.size() + "]:" + program.toString());
}
public void Init() {
CP = 0;
program = new Vector();
}
public Instruction CurrentInst() {
return (Instruction)program.get(CP);
}
abstract public boolean Stop();
public void Next() {
CP++;
}
}