// 2r> private static void fromR2() { var top = ReturnStack.Pop(); Stack.Push(ReturnStack.Pop()); Stack.Push(top); }
void ReturnStackOverflowTest() { Int16[] data = { 0, 1, 2, 3, 4 }; ReturnStack rs = MakeStack(data.GetLength(0) - 1); Assert.Throws <StackOverflowException>(() => data.Any(i => { rs.Push(data[i]); return(false); })); }
// 2>r private static void ontoR2() { var top = Stack.Pop(); ReturnStack.Push(Stack.Pop()); ReturnStack.Push(top); }
public void ExecuteByhInterpreter(Interpreter machine) { #if _DEBUG Console.WriteLine("Opcodes Executing with machine "+machine); #endif //remember the old pStack of the machine and replace with a new stack segment. ReturnStack s= new ReturnStack(machine); machine.Process(ops); s.Return(); }
void ReturnStackPushPopTest() { Int16[] data = { 0, 1, 2, 3, 4, 5 }; ReturnStack rs = MakeStack(data.GetLength(0)); data.Any(i => { rs.Push(data[i]); return(false); }); Assert.True(rs.Position == 0); Assert.True(data.All(i => rs.Pop() == data[rs.Size - rs.Position])); }
ReturnStack MakeStack(int size) { ReturnStack stack = new ReturnStack(size); stack.StackOverflow += () => throw new StackOverflowException(); stack.StackUnderflow += () => throw new StackUnderflowException(); return(stack); }
public void ExecuteByhInterpreter(Interpreter machine) { #if _DEBUG Console.WriteLine("Opcodes Executing with machine " + machine); #endif //remember the old pStack of the machine and replace with a new stack segment. ReturnStack s = new ReturnStack(machine); machine.Process(ops); s.Return(); }
public void Reset() { // NOT reset: TextBuffer, Words, Memory and LastCompiledWord DataStack.Clear(); ReturnStack.Clear(); ControlFlowStack.Clear(); ActiveExitWordName = null; IsCompileMode = false; CompilingWord = null; IsMultilineCommentMode = false; }
private IArithmeticLogicUnit BuildALU() { IAddressRegister addressRegister = new AddressRegister(); IGeneralPurposeRegisters generalPurposeRegisters = new GeneralPurposeRegisters(); IInstructionPointerRegister ipr = new InstructionPointerRegister(); IReturnStack returnStack = new ReturnStack(); IArithmeticLogicUnit alu = new ArithmeticLogicUnit( addressRegister, generalPurposeRegisters, ipr, returnStack ); return(alu); }
// Clean; up all the inputs public void cleanFields() { DataStack.Clear(); ReturnStack.Clear(); PADarea.Clear(); ParsedInput.Clear(); LoopCurrIndexes[0] = 0; LoopCurrIndexes[1] = 0; LoopCurrIndexes[2] = 0; looplabelptr = 0; outerptr = 0; innerptr = 0; paramfieldptr = 0; inputarea = ""; outputarea = ""; helpcommentfield = ""; pause = false; }
// r@ private static void copyR() { Stack.Push(ReturnStack.Peek()); }
// r> private static void fromR() { Stack.Push(ReturnStack.Pop()); }
// The return stack being a part of the actual call stack doesn't make a // lot of sense in .Net so it's just a second stack, indistinguishable in all // but usage from the Data stack. // >r private static void ontoR() { ReturnStack.Push(Stack.Pop()); }
public InterpreterState(Stack stack, FloatingPointStack floatingPointStack, ObjectStack objectStack, ReturnStack returnStack, ExceptionStack exceptionStack, InputSourceStack inputSourceStack, Heap heap, ObjectHeap objectHeap, IWordsList wordsList) { Stack = stack ?? throw new ArgumentNullException(nameof(stack)); FloatingPointStack = floatingPointStack ?? throw new ArgumentNullException(nameof(floatingPointStack)); ObjectStack = objectStack ?? throw new ArgumentNullException(nameof(objectStack)); ReturnStack = returnStack ?? throw new ArgumentNullException(nameof(returnStack)); ExceptionStack = exceptionStack ?? throw new ArgumentNullException(nameof(exceptionStack)); InputSourceStack = inputSourceStack ?? throw new ArgumentNullException(nameof(inputSourceStack)); Heap = heap ?? throw new ArgumentNullException(nameof(heap)); ObjectHeap = objectHeap ?? throw new ArgumentNullException(nameof(objectHeap)); Picture = string.Empty; WordsList = wordsList ?? throw new ArgumentNullException(nameof(wordsList)); _stacksRegistry = new Dictionary <string, IStack>(); RegisterDefaultStacks(); SetupDefaults(); }