public Function(string name, byte[] bytecode) { this.name = name; this.bytecode = new Bytecode(bytecode); //Console.WriteLine("Function bytecode:"); //Console.WriteLine(String.Join(" ", bytecode)); }
public void JumpTo(Bytecode bytecode) { bytecodeStack.Push(currentBytecode); currentBytecode = bytecode; }
// calling plain JumpTo goes back one bytecode. if there is no more bytecodes left, end the program public bool JumpTo() { if (!bytecodeStack.Any()) return true; currentBytecode = bytecodeStack.Pop(); // take the previous return false; }
public void Load(CompiledProgram program) { stack = new Stack<object>(MaxStackSize); scope = new Scope(null); bytecodeStack = new Stack<Bytecode>(); currentBytecode = program.GetBytecode(); Console.WriteLine("Program loaded"); }