Esempio n. 1
0
        /**
         * Gets the token representation of this item in RPN
         *
         * @return the bytes applicable to this formula
         */
        public override byte[] getBytes()
        {
            // Get the data for the operands
            ParseItem[] operands = getOperands();
            byte[]      data     = new byte[0];

            for (int i = 0; i < operands.Length; i++)
            {
                byte[] opdata = operands[i].getBytes();

                // Grow the array
                byte[] newdata = new byte[data.Length + opdata.Length];
                System.Array.Copy(data, 0, newdata, 0, data.Length);
                System.Array.Copy(opdata, 0, newdata, data.Length, opdata.Length);
                data = newdata;
            }

            // Add on the operator byte
            byte[] fixedData = new byte[data.Length + 3];
            System.Array.Copy(data, 0, fixedData, 0, data.Length);
            fixedData[data.Length] = !useAlternateCode() ? Token.FUNCTION.getCode() : Token.FUNCTION.getCode2();
            IntegerHelper.getTwoBytes(function.getCode(), fixedData, data.Length + 1);

            return(fixedData);
        }
Esempio n. 2
0
        /**
         * Gets the token representation of this item in RPN
         *
         * @return the bytes applicable to this formula
         */
        public override byte[] getBytes()
        {
            handleSpecialCases();

            // Get the data for the operands - in the correct order
            ParseItem[] operands = getOperands();
            byte[]      data     = new byte[0];

            for (int i = 0; i < operands.Length; i++)
            {
                byte[] opdata = operands[i].getBytes();

                // Grow the array
                byte[] newdata = new byte[data.Length + opdata.Length];
                System.Array.Copy(data, 0, newdata, 0, data.Length);
                System.Array.Copy(opdata, 0, newdata, data.Length, opdata.Length);
                data = newdata;
            }

            // Add on the operator byte
            byte[] fixedData = new byte[data.Length + 4];
            System.Array.Copy(data, 0, fixedData, 0, data.Length);
            fixedData[data.Length]     = !useAlternateCode() ? Token.FUNCTIONVARARG.getCode() : Token.FUNCTIONVARARG.getCode2();
            fixedData[data.Length + 1] = (byte)arguments;
            IntegerHelper.getTwoBytes(function.getCode(), fixedData, data.Length + 2);

            return(fixedData);
        }