Beispiel #1
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;
 }
Beispiel #2
0
        public void TestMap()
        {
            var makeMap = "1 2 \"foo\" \"bar\" 2 tomap";

            PiRun(makeMap);

            TestMapContents();
            AssertEmpty();

            // expand map to the stack
            PiRun(makeMap + " expand");
            //_Exec.WriteDataStack(10);
            AssertPop(2);
            Assert.AreEqual(4, DataStack.Count);
            DataStack.Clear();

            // remake map from stack contents
            PiRun(makeMap + " expand tomap");
            TestMapContents();
            AssertEmpty();
        }
        /// <summary>
        /// Add options to the internal mapping of EOperation enum to
        /// functor that does the work for that operation.
        /// </summary>
        private void AddOperations()
        {
            _actions[EOperation.Plus] = () =>
            {
                var b = RPop();
                var a = RPop();
                Push(a + b);
            };

            _actions[EOperation.Minus] = () =>
            {
                var a = RPop();
                var b = RPop();
                Push(b - a);
            };

            _actions[EOperation.Multiply]               = () => Push(RPop() * RPop());
            _actions[EOperation.Divide]                 = Divide;
            _actions[EOperation.Suspend]                = Suspend;
            _actions[EOperation.Resume]                 = Resume;
            _actions[EOperation.Replace]                = Replace;
            _actions[EOperation.Break]                  = DebugBreak;
            _actions[EOperation.Store]                  = StoreValue;
            _actions[EOperation.Retrieve]               = GetValue;
            _actions[EOperation.Assert]                 = Assert;
            _actions[EOperation.Equiv]                  = Equiv;
            _actions[EOperation.NotEquiv]               = NotEquiv;
            _actions[EOperation.Not]                    = () => Push(!RPop <bool>());
            _actions[EOperation.LogicalAnd]             = LogicalAnd;
            _actions[EOperation.LogicalOr]              = LogicalOr;
            _actions[EOperation.LogicalXor]             = LogicalXor;
            _actions[EOperation.ToArray]                = ToArray;
            _actions[EOperation.ToList]                 = ToArray;
            _actions[EOperation.ToMap]                  = ToMap;
            _actions[EOperation.ToSet]                  = ToSet;
            _actions[EOperation.Size]                   = GetSize;
            _actions[EOperation.PushFront]              = PushFront;
            _actions[EOperation.PushBack]               = PushBack;
            _actions[EOperation.Remove]                 = Remove;
            _actions[EOperation.Expand]                 = Expand;
            _actions[EOperation.Insert]                 = Insert;
            _actions[EOperation.New]                    = New;
            _actions[EOperation.GetType]                = GetTypeOf;
            _actions[EOperation.At]                     = At;
            _actions[EOperation.Has]                    = Has;
            _actions[EOperation.DebugPrintDataStack]    = DebugPrintDataStack;
            _actions[EOperation.DebugPrintContinuation] = DebugPrintContinuation;
            _actions[EOperation.DebugPrintContextStack] = DebugPrintContextStack;
            _actions[EOperation.DebugPrint]             = DebugTrace;
            _actions[EOperation.Depth]                  = () => Push(DataStack.Count);
            _actions[EOperation.SetFloatPrecision]      = SetFloatPrecision;
            _actions[EOperation.Write]                  = () => Write(RPop());
            _actions[EOperation.WriteLine]              = () => WriteLine(RPop());
            _actions[EOperation.If]                     = If;
            _actions[EOperation.IfElse]                 = IfElse;
            _actions[EOperation.Assign]                 = Assign;
            _actions[EOperation.GetMember]              = GetMember;
            _actions[EOperation.SetMember]              = SetMember;
            _actions[EOperation.ForEachIn]              = ForEachIn;
            _actions[EOperation.ForLoop]                = ForLoop;
            _actions[EOperation.Freeze]                 = Freeze;
            _actions[EOperation.Thaw]                   = Thaw;
            _actions[EOperation.Drop]                   = () => Pop();
            _actions[EOperation.DropN]                  = DropN;
            _actions[EOperation.Swap]                   = Swap;
            _actions[EOperation.Pick]                   = Pick;
            _actions[EOperation.Rot]                    = Rot;
            _actions[EOperation.Over]                   = Over;
            _actions[EOperation.Dup]                    = Dup;
            _actions[EOperation.Clear]                  = () => DataStack.Clear();
            _actions[EOperation.Less]                   = Less;
            _actions[EOperation.LessOrEquiv]            = LessEquiv;
            _actions[EOperation.Greater]                = Greater;
            _actions[EOperation.GreaterOrEquiv]         = GreaterEquiv;
            _actions[EOperation.Self]                   = () => Push(_current);
            _actions[EOperation.Exists]                 = Exists;
        }