コード例 #1
0
        // 2r>
        private static void fromR2()
        {
            var top = ReturnStack.Pop();

            Stack.Push(ReturnStack.Pop());
            Stack.Push(top);
        }
コード例 #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); }));
        }
コード例 #3
0
        // 2>r
        private static void ontoR2()
        {
            var top = Stack.Pop();

            ReturnStack.Push(Stack.Pop());
            ReturnStack.Push(top);
        }
コード例 #4
0
ファイル: Executable.cs プロジェクト: Nicodemes/BackScript
        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();
        }
コード例 #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]));
        }
コード例 #6
0
        ReturnStack MakeStack(int size)
        {
            ReturnStack stack = new ReturnStack(size);

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

            return(stack);
        }
コード例 #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();
        }
コード例 #8
0
ファイル: Environment.cs プロジェクト: HerbM/ForthInterpreter
        public void Reset()
        {
            // NOT reset: TextBuffer, Words, Memory and LastCompiledWord
            DataStack.Clear();
            ReturnStack.Clear();
            ControlFlowStack.Clear();

            ActiveExitWordName     = null;
            IsCompileMode          = false;
            CompilingWord          = null;
            IsMultilineCommentMode = false;
        }
コード例 #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);
        }
コード例 #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;
 }
コード例 #11
0
 // r@
 private static void copyR()
 {
     Stack.Push(ReturnStack.Peek());
 }
コード例 #12
0
 // r>
 private static void fromR()
 {
     Stack.Push(ReturnStack.Pop());
 }
コード例 #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());
        }
コード例 #14
0
ファイル: InterpreterState.cs プロジェクト: enif77/EFrt
        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();
        }