Ejemplo n.º 1
0
        // 2r>
        private static void fromR2()
        {
            var top = ReturnStack.Pop();

            Stack.Push(ReturnStack.Pop());
            Stack.Push(top);
        }
Ejemplo n.º 2
0
        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); }));
        }
Ejemplo n.º 3
0
        // 2>r
        private static void ontoR2()
        {
            var top = Stack.Pop();

            ReturnStack.Push(Stack.Pop());
            ReturnStack.Push(top);
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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]));
        }
Ejemplo n.º 6
0
        ReturnStack MakeStack(int size)
        {
            ReturnStack stack = new ReturnStack(size);

            stack.StackOverflow  += () => throw new StackOverflowException();
            stack.StackUnderflow += () => throw new StackUnderflowException();

            return(stack);
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        public void Reset()
        {
            // NOT reset: TextBuffer, Words, Memory and LastCompiledWord
            DataStack.Clear();
            ReturnStack.Clear();
            ControlFlowStack.Clear();

            ActiveExitWordName     = null;
            IsCompileMode          = false;
            CompilingWord          = null;
            IsMultilineCommentMode = false;
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 //  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;
 }
Ejemplo n.º 11
0
 // r@
 private static void copyR()
 {
     Stack.Push(ReturnStack.Peek());
 }
Ejemplo n.º 12
0
 // r>
 private static void fromR()
 {
     Stack.Push(ReturnStack.Pop());
 }
Ejemplo n.º 13
0
        // 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());
        }
Ejemplo n.º 14
0
        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();
        }