Пример #1
0
        public override ProgNodeValue ExecBoxing(ProgNodeValue left, ProgNodeValue right, int type)
        {
            ProgNodeValue result = null;

            switch (type)
            {
            case TYPE_FLOAT:
                float fvalue = (float)(Math.Pow(left.GetFloat(), right.GetFloat()));
                result = new ProgNodeValue(fvalue);
                break;
            }

            return(result);
        }
        /**************************/
        /*** Override Functions ***/
        /**************************/

        public override ProgNodeValue ExecBoxing(ProgNodeValue left, ProgNodeValue right, int type)
        {
            ProgNodeValue result = null;

            switch (type)
            {
            case TYPE_FLOAT:
                float fvalue = left.GetFloat() * right.GetFloat();
                result = new ProgNodeValue(fvalue);
                break;

            case TYPE_INTEGER:
                int ivalue = left.GetInteger() * right.GetInteger();
                result = new ProgNodeValue(ivalue);
                break;
            }

            return(result);
        }
Пример #3
0
        public void Assign(ProgNodeValue value, int index)
        {
            switch (Type)
            {
            case SymbolTableRecType.INTEGER:
                values[index] = new ProgNodeValue(value.GetInteger());
                break;

            case SymbolTableRecType.FLOAT:
                values[index] = new ProgNodeValue(value.GetFloat());
                break;

            case SymbolTableRecType.STRING:
                values[index] = new ProgNodeValue(value.GetString());
                break;

            case SymbolTableRecType.BOOLEAN:
                values[index] = new ProgNodeValue(value.GetBoolean());
                break;
            }
        }
Пример #4
0
        /**************************/
        /*** Override Functions ***/
        /**************************/

        public override ProgNodeValue ExecBoxing(ProgNodeValue left, ProgNodeValue right, int action)
        {
            bool value = false;

            switch (action)
            {
            case BOX_INTEGER:
                int iLeft  = left.GetInteger();
                int iRight = right.GetInteger();

                switch (type)
                {
                case TokenType.LT:
                    value = iLeft < iRight;
                    break;

                case TokenType.LE:
                    value = iLeft <= iRight;
                    break;

                case TokenType.GT:
                    value = iLeft > iRight;
                    break;

                case TokenType.GE:
                    value = iLeft >= iRight;
                    break;

                case TokenType.NE:
                    value = iLeft != iRight;
                    break;
                }

                break;

            case BOX_FLOAT:
                float fLeft  = left.GetFloat();
                float fRight = right.GetFloat();

                switch (type)
                {
                case TokenType.LT:
                    value = fLeft < fRight;
                    break;

                case TokenType.LE:
                    value = fLeft <= fRight;
                    break;

                case TokenType.GT:
                    value = fLeft > fRight;
                    break;

                case TokenType.GE:
                    value = fLeft >= fRight;
                    break;

                case TokenType.NE:
                    value = fLeft != fRight;
                    break;
                }

                break;
            }

            return(new ProgNodeValue(value));
        }