Ejemplo n.º 1
0
        // ( val -- val val ) Duplicates the argument on top of the stack
        public void doDup(ref GlobalSimpleProps gsp)
        {
            object arg;

            arg = gsp.Pop(gsp.DataStack);
            gsp.Push(gsp.DataStack);
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 2
0
        // ( val1 val2 -- val2 val1 ) Swaps the positions of the top two stack arguments
        public void doSwap(ref GlobalSimpleProps gsp)
        {
            object arg1, arg2;

            arg2        = gsp.Pop(gsp.DataStack);
            arg1        = gsp.Pop(gsp.DataStack);
            gsp.Scratch = arg2;
            gsp.Push(gsp.DataStack);
            gsp.Scratch = arg1;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 3
0
        // ( val1 val2 -- val1 val2 val1 ) Copies second stack argument to the top of the stack
        public void doOver(ref GlobalSimpleProps gsp)
        {
            object val2 = gsp.Pop(gsp.DataStack);
            object val1 = gsp.Pop(gsp.DataStack);

            gsp.Scratch = val1;
            gsp.Push(gsp.DataStack);
            gsp.Scratch = val2;
            gsp.Push(gsp.DataStack);
            gsp.Scratch = val1;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 4
0
        // ( -- location ) Returns address of the next available dictionary location
        public void doHere(ref GlobalSimpleProps gsp)
        {
            int hereLoc = gsp.Cfb.Address.Count;

            gsp.Scratch = hereLoc;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 5
0
        // ( -- datetime ) Puts the current datetime on the stack
        public void doNow(ref GlobalSimpleProps gsp)
        {
            DateTime now = DateTime.Now;

            gsp.Scratch = now;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 6
0
        // Used internally by doCreate - is not compiled into the dictionary
        public void doMyAddress(ref GlobalSimpleProps gsp)
        {
            CreoleWord cw = gsp.Cfb.Address[gsp.InnerPtr];

            gsp.Scratch = cw.IndexField;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 7
0
        // ( n1 n2 -- quotient ) Divides two numbers on the stack
        public void doDivide(ref GlobalSimpleProps gsp)
        {
            object arg1, arg2, quotient;

            arg2        = gsp.Pop(gsp.DataStack);
            arg1        = gsp.Pop(gsp.DataStack);
            quotient    = Convert.ToDouble(arg1) / Convert.ToDouble(arg2);
            gsp.Scratch = quotient;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 8
0
        // ( n1 n2 -- product ) Multiplies two numbers on the stack
        public void doMultiply(ref GlobalSimpleProps gsp)
        {
            object arg1, arg2, product;

            arg2        = gsp.Pop(gsp.DataStack);
            arg1        = gsp.Pop(gsp.DataStack);
            product     = Convert.ToDouble(arg1) * Convert.ToDouble(arg2);
            gsp.Scratch = product;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 9
0
        // ( n1 n2 -- diff ) Subtracts two numbers on the stack
        public void doMinus(ref GlobalSimpleProps gsp)
        {
            object arg1, arg2, diff;

            arg2        = gsp.Pop(gsp.DataStack);
            arg1        = gsp.Pop(gsp.DataStack);
            diff        = Convert.ToDouble(arg1) - Convert.ToDouble(arg2);
            gsp.Scratch = diff;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 10
0
        // ( n1 n2 -- sum ) Adds two numbers on the stack
        public void doPlus(ref GlobalSimpleProps gsp)
        {
            object arg1, arg2, sum;

            arg2        = gsp.Pop(gsp.DataStack);
            arg1        = gsp.Pop(gsp.DataStack);
            sum         = Convert.ToDouble(arg1) + Convert.ToDouble(arg2);
            gsp.Scratch = sum;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 11
0
        // ( n1 n2 -- remainder ) Returns remainder of division operation
        public void doMod(ref GlobalSimpleProps gsp)
        {
            object arg1, arg2, remainder;

            arg2        = gsp.Pop(gsp.DataStack);
            arg1        = gsp.Pop(gsp.DataStack);
            remainder   = (int)arg1 % (int)arg2;
            gsp.Scratch = remainder;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 12
0
        // ( val -- opval ) -1 if 0, 0 otherwise
        public void doNot(ref GlobalSimpleProps gsp)
        {
            object val = gsp.Pop(gsp.DataStack);

            if (Convert.ToInt64(val) == 0)
            {
                gsp.Scratch = -1;
            }
            else
            {
                gsp.Scratch = 0;
            }
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 13
0
        // ( val1 val2 -- flag ) -1 if less than or equal to, 0 otherwise
        public void doLessThanOrEquals(ref GlobalSimpleProps gsp)
        {
            object val2 = gsp.Pop(gsp.DataStack);
            object val1 = gsp.Pop(gsp.DataStack);

            if (Convert.ToInt64(val1) <= Convert.ToInt64(val2))
            {
                gsp.Scratch = -1;
            }
            else
            {
                gsp.Scratch = 0;
            }
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 14
0
        // ( val1 val2 -- flag ) -1 if greater than, 0 otherwise
        public void doGreaterThan(ref GlobalSimpleProps gsp)
        {
            object val2 = gsp.Pop(gsp.DataStack);
            object val1 = gsp.Pop(gsp.DataStack);

            if (Convert.ToInt64(val1) > Convert.ToInt64(val2))
            {
                gsp.Scratch = -1;
            }
            else
            {
                gsp.Scratch = 0;
            }
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 15
0
        // ( val1 val2 -- flag ) 0 if equal, -1 otherwise
        public void doNotEquals(ref GlobalSimpleProps gsp)
        {
            object val2 = gsp.Pop(gsp.DataStack);
            object val1 = gsp.Pop(gsp.DataStack);

            if (val1.Equals(val2))
            {
                gsp.Scratch = 0;
            }
            else
            {
                gsp.Scratch = -1;
            }
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 16
0
        // val1 val2 -- flag ) -1 if one and only one argument is non-zero, 0 otherwise
        public void doXor(ref GlobalSimpleProps gsp)
        {
            object val2 = gsp.Pop(gsp.DataStack);
            object val1 = gsp.Pop(gsp.DataStack);

            if ((Convert.ToInt64(val2) != 0 || Convert.ToInt64(val1) != 0) && !(Convert.ToInt64(val1) != 0 || Convert.ToInt64(val2) != 0))
            {
                gsp.Scratch = -1;
            }
            else
            {
                gsp.Scratch = 0;
            }
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 17
0
        // ( val1 val2 -- flag ) -1 if both arguments are non-zero, 0 otherwise
        public void doAnd(ref GlobalSimpleProps gsp)
        {
            object val2 = gsp.Pop(gsp.DataStack);
            object val1 = gsp.Pop(gsp.DataStack);

            if (Convert.ToInt64(val2) != 0 && Convert.ToInt64(val1) != 9)
            {
                gsp.Scratch = -1;
            }
            else
            {
                gsp.Scratch = 0;
            }
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 18
0
        // ( -- list ) List compiler
        public void compileList(ref GlobalSimpleProps gsp)
        {
            List <string> compiledList = new List <string>();

            gsp.OuterPtr += 1;
            Regex rx      = new Regex(@"\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            bool  isFound = rx.IsMatch(gsp.ParsedInput[gsp.OuterPtr]);

            while (!isFound)
            {
                compiledList.Add(gsp.ParsedInput[gsp.OuterPtr] + " ");
                gsp.OuterPtr++;
                isFound = rx.IsMatch(gsp.ParsedInput[gsp.OuterPtr]);
            }
            string joinedList = compiledList.ToString().Trim();

            gsp.Scratch = joinedList;
            gsp.Push(gsp.DataStack);
        }
Ejemplo n.º 19
0
        // Run time code for colon definitions
        public void doColon(ref GlobalSimpleProps gsp)
        {
            CreoleWord currWord   = gsp.Cfb.Address[gsp.InnerPtr];
            List <int> paramField = currWord.ParamField;

            while (gsp.ParamFieldPtr < paramField.Count)
            {
                int       addrInPF  = paramField[gsp.ParamFieldPtr];
                Codefield codeField = gsp.Cfb.Address[addrInPF].CodeField;
                gsp.ParamFieldPtr++;
                ReturnLoc rLoc = new ReturnLoc(gsp.InnerPtr, gsp.ParamFieldPtr);
                gsp.Scratch = rLoc;
                gsp.Push(gsp.ReturnStack);
                codeField(ref gsp);
                rLoc              = (ReturnLoc)gsp.Pop(gsp.ReturnStack);
                gsp.InnerPtr      = rLoc.DictAddr;
                gsp.ParamFieldPtr = rLoc.ParamFieldAddr;
            }
        }
Ejemplo n.º 20
0
 // ( -- n ) Returns the stack depth
 public void doDepth(ref GlobalSimpleProps gsp)
 {
     gsp.Scratch = gsp.DataStack.Count;
     gsp.Push(gsp.DataStack);
 }