View over a Qil atomic value literal (of any type).
Don't construct QIL nodes directly; instead, use the QilFactory.
Inheritance: QilNode
Esempio n. 1
0
        public QilLiteral LiteralInt64(long value)
        {
            QilLiteral n = new QilLiteral(QilNodeType.LiteralInt64, value);

            n.XmlType = this.typeCheck.CheckLiteralInt64(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 2
0
        public QilLiteral LiteralDouble(double value)
        {
            QilLiteral n = new QilLiteral(QilNodeType.LiteralDouble, value);

            n.XmlType = this.typeCheck.CheckLiteralDouble(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 3
0
        public QilLiteral LiteralInt32(int value)
        {
            QilLiteral n = new QilLiteral(QilNodeType.LiteralInt32, value);

            n.XmlType = _typeCheck.CheckLiteralInt32(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 4
0
        public QilLiteral LiteralString(string value)
        {
            QilLiteral n = new QilLiteral(QilNodeType.LiteralString, value);

            n.XmlType = this.typeCheck.CheckLiteralString(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 5
0
        public QilLiteral LiteralDecimal(decimal value)
        {
            QilLiteral n = new QilLiteral(QilNodeType.LiteralDecimal, value);

            n.XmlType = this.typeCheck.CheckLiteralDecimal(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 6
0
        public QilLiteral LiteralObject(object value)
        {
            QilLiteral n = new QilLiteral(QilNodeType.LiteralObject, value);

            n.XmlType = this.typeCheck.CheckLiteralObject(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 7
0
        public QilLiteral LiteralType(XmlQueryType value)
        {
            QilLiteral n = new QilLiteral(QilNodeType.LiteralType, value);

            n.XmlType = this.typeCheck.CheckLiteralType(n);
            TraceNode(n);
            return(n);
        }
Esempio n. 8
0
 /// <summary>
 /// Generate code for QilNodeType.LiteralDouble.
 /// </summary>
 protected override QilNode VisitLiteralDouble(QilLiteral ndDbl)
 {
     _helper.Emit(OpCodes.Ldc_R8, (double)ndDbl);
     _iterCurr.Storage = StorageDescriptor.Stack(typeof(double), false);
     return ndDbl;
 }
 public XmlQueryType CheckLiteralDouble(QilLiteral node) {
     CheckLiteralValue(node, typeof(double));
     return XmlQueryTypeFactory.DoubleX;
 }
 public XmlQueryType CheckLiteralInt32(QilLiteral node) {
     CheckLiteralValue(node, typeof(int));
     return XmlQueryTypeFactory.IntX;
 }
Esempio n. 11
0
 protected virtual QilNode VisitLiteralObject(QilLiteral n) { return VisitChildren(n); }
Esempio n. 12
0
 public XmlQueryType CheckLiteralObject(QilLiteral node)
 {
     Check(node.Value != null, node, "Literal value is null");
     return(XmlQueryTypeFactory.ItemS);
 }
Esempio n. 13
0
 public QilLiteral LiteralType(XmlQueryType value) {
     QilLiteral n = new QilLiteral(QilNodeType.LiteralType, value);
     n.XmlType = this.typeCheck.CheckLiteralType(n);
     TraceNode(n);
     return n;
 }
Esempio n. 14
0
 public QilLiteral LiteralDecimal(decimal value) {
     QilLiteral n = new QilLiteral(QilNodeType.LiteralDecimal, value);
     n.XmlType = this.typeCheck.CheckLiteralDecimal(n);
     TraceNode(n);
     return n;
 }
Esempio n. 15
0
 public QilLiteral LiteralDouble(double value) {
     QilLiteral n = new QilLiteral(QilNodeType.LiteralDouble, value);
     n.XmlType = this.typeCheck.CheckLiteralDouble(n);
     TraceNode(n);
     return n;
 }
Esempio n. 16
0
 public QilLiteral LiteralInt64(long value) {
     QilLiteral n = new QilLiteral(QilNodeType.LiteralInt64, value);
     n.XmlType = this.typeCheck.CheckLiteralInt64(n);
     TraceNode(n);
     return n;
 }
Esempio n. 17
0
 public QilLiteral LiteralString(string value) {
     QilLiteral n = new QilLiteral(QilNodeType.LiteralString, value);
     n.XmlType = this.typeCheck.CheckLiteralString(n);
     TraceNode(n);
     return n;
 }
Esempio n. 18
0
 /// <summary>
 /// Generate code for QilNodeType.LiteralDecimal.
 /// </summary>
 protected override QilNode VisitLiteralDecimal(QilLiteral ndDec)
 {
     _helper.ConstructLiteralDecimal((decimal)ndDec);
     _iterCurr.Storage = StorageDescriptor.Stack(typeof(decimal), false);
     return ndDec;
 }
Esempio n. 19
0
 public XmlQueryType CheckLiteralInt64(QilLiteral node)
 {
     CheckLiteralValue(node, typeof(long));
     return(XmlQueryTypeFactory.IntegerX);
 }
Esempio n. 20
0
 public XmlQueryType CheckLiteralDecimal(QilLiteral node)
 {
     CheckLiteralValue(node, typeof(decimal));
     return(XmlQueryTypeFactory.DecimalX);
 }
Esempio n. 21
0
 public QilLiteral LiteralObject(object value) {
     QilLiteral n = new QilLiteral(QilNodeType.LiteralObject, value);
     n.XmlType = this.typeCheck.CheckLiteralObject(n);
     TraceNode(n);
     return n;
 }
Esempio n. 22
0
 /// <summary>
 /// Generate code for QilNodeType.LiteralInt32.
 /// </summary>
 protected override QilNode VisitLiteralInt32(QilLiteral ndInt)
 {
     _helper.LoadInteger((int)ndInt);
     _iterCurr.Storage = StorageDescriptor.Stack(typeof(int), false);
     return ndInt;
 }
 /// <summary>
 /// Return true if arithmetic operation "opType" can be computed over two literal operands without causing
 /// an overflow or divide by zero exception.
 /// </summary>
 private bool CanFoldArithmetic(QilNodeType opType, QilLiteral left, QilLiteral right) {
     return (FoldArithmetic(opType, left, right) is QilLiteral);
 }
        /// <summary>
        /// Compute the arithmetic operation "opType" over two literal operands and return the result as a QilLiteral.
        /// Arithmetic operations are always checked; in the case of an overflow or divide by zero exception, return
        /// the unfolded result.
        /// </summary>
        private QilNode FoldArithmetic(QilNodeType opType, QilLiteral left, QilLiteral right) {
            Debug.Assert(left.NodeType == right.NodeType);

            // Catch any overflow or divide by zero exceptions
            try {
                checked {
                    switch (left.NodeType) {
                        case QilNodeType.LiteralInt32: {
                            int intLeft = left;
                            int intRight = right;

                            switch (opType) {
                                case QilNodeType.Add: return f.LiteralInt32(intLeft + intRight);
                                case QilNodeType.Subtract: return f.LiteralInt32(intLeft - intRight);
                                case QilNodeType.Multiply: return f.LiteralInt32(intLeft * intRight);
                                case QilNodeType.Divide: return f.LiteralInt32(intLeft / intRight);
                                case QilNodeType.Modulo: return f.LiteralInt32(intLeft % intRight);
                            }
                            break;
                        }

                        case QilNodeType.LiteralInt64: {
                            long lngLeft = left;
                            long lngRight = right;

                            switch (opType) {
                                case QilNodeType.Add: return f.LiteralInt64(lngLeft + lngRight);
                                case QilNodeType.Subtract: return f.LiteralInt64(lngLeft - lngRight);
                                case QilNodeType.Multiply: return f.LiteralInt64(lngLeft * lngRight);
                                case QilNodeType.Divide: return f.LiteralInt64(lngLeft / lngRight);
                                case QilNodeType.Modulo: return f.LiteralInt64(lngLeft % lngRight);
                            }
                            break;
                        }

                        case QilNodeType.LiteralDecimal: {
                            decimal lngLeft = left;
                            decimal lngRight = right;

                            switch (opType) {
                                case QilNodeType.Add: return f.LiteralDecimal(lngLeft + lngRight);
                                case QilNodeType.Subtract: return f.LiteralDecimal(lngLeft - lngRight);
                                case QilNodeType.Multiply: return f.LiteralDecimal(lngLeft * lngRight);
                                case QilNodeType.Divide: return f.LiteralDecimal(lngLeft / lngRight);
                                case QilNodeType.Modulo: return f.LiteralDecimal(lngLeft % lngRight);
                            }
                            break;
                        }

                        case QilNodeType.LiteralDouble: {
                            double lngLeft = left;
                            double lngRight = right;

                            switch (opType) {
                                case QilNodeType.Add: return f.LiteralDouble(lngLeft + lngRight);
                                case QilNodeType.Subtract: return f.LiteralDouble(lngLeft - lngRight);
                                case QilNodeType.Multiply: return f.LiteralDouble(lngLeft * lngRight);
                                case QilNodeType.Divide: return f.LiteralDouble(lngLeft / lngRight);
                                case QilNodeType.Modulo: return f.LiteralDouble(lngLeft % lngRight);
                            }
                            break;
                        }
                    }
                }
            }
            catch (OverflowException) {
            }
            catch (DivideByZeroException) {
            }

            // An error occurred, so don't fold operationo
            switch (opType) {
                case QilNodeType.Add: return f.Add(left, right);
                case QilNodeType.Subtract: return f.Subtract(left, right);
                case QilNodeType.Multiply: return f.Multiply(left, right);
                case QilNodeType.Divide: return f.Divide(left, right);
                case QilNodeType.Modulo: return f.Modulo(left, right);
            }

            Debug.Assert(false, "Cannot fold this arithmetic operation: " + opType);
            return null;
        }
Esempio n. 25
0
 protected override QilNode VisitLiteralDecimal(QilLiteral n)
 {
     return(NoReplace(n));
 }
Esempio n. 26
0
 protected virtual QilNode VisitLiteralDecimal(QilLiteral n) { return VisitChildren(n); }
Esempio n. 27
0
 protected override QilNode VisitLiteralObject(QilLiteral n)
 {
     return(NoReplace(n));
 }
 public XmlQueryType CheckLiteralString(QilLiteral node) {
     CheckLiteralValue(node, typeof(string));
     return XmlQueryTypeFactory.StringX;
 }
 public XmlQueryType CheckLiteralType(QilLiteral node) {
     CheckLiteralValue(node, typeof(XmlQueryType));
     return (XmlQueryType) node;
 }
 public XmlQueryType CheckLiteralInt64(QilLiteral node) {
     CheckLiteralValue(node, typeof(long));
     return XmlQueryTypeFactory.IntegerX;
 }
Esempio n. 31
0
 public XmlQueryType CheckLiteralString(QilLiteral node)
 {
     CheckLiteralValue(node, typeof(string));
     return(XmlQueryTypeFactory.StringX);
 }
 public XmlQueryType CheckLiteralDecimal(QilLiteral node) {
     CheckLiteralValue(node, typeof(decimal));
     return XmlQueryTypeFactory.DecimalX;
 }
Esempio n. 33
0
 /// <summary>
 /// Generate code for QilNodeType.LiteralInt64.
 /// </summary>
 protected override QilNode VisitLiteralInt64(QilLiteral ndLong)
 {
     _helper.Emit(OpCodes.Ldc_I8, (long)ndLong);
     _iterCurr.Storage = StorageDescriptor.Stack(typeof(long), false);
     return ndLong;
 }
 public XmlQueryType CheckLiteralObject(QilLiteral node) {
     Check(node.Value != null, node, "Literal value is null");
     return XmlQueryTypeFactory.ItemS;
 }
Esempio n. 35
0
 protected override QilNode VisitLiteralDecimal(QilLiteral n) { return NoReplace(n); }
Esempio n. 36
0
 public XmlQueryType CheckLiteralInt32(QilLiteral node)
 {
     CheckLiteralValue(node, typeof(int));
     return(XmlQueryTypeFactory.IntX);
 }
Esempio n. 37
0
 protected override QilNode VisitLiteralObject(QilLiteral n) { return NoReplace(n); }
Esempio n. 38
0
 public XmlQueryType CheckLiteralDouble(QilLiteral node)
 {
     CheckLiteralValue(node, typeof(double));
     return(XmlQueryTypeFactory.DoubleX);
 }
Esempio n. 39
0
 protected virtual QilNode VisitLiteralDecimal(QilLiteral n)
 {
     return(VisitChildren(n));
 }
Esempio n. 40
0
 public XmlQueryType CheckLiteralType(QilLiteral node)
 {
     CheckLiteralValue(node, typeof(XmlQueryType));
     return((XmlQueryType)node);
 }
Esempio n. 41
0
 public QilLiteral LiteralInt32(int value)
 {
     QilLiteral n = new QilLiteral(QilNodeType.LiteralInt32, value);
     n.XmlType = _typeCheck.CheckLiteralInt32(n);
     TraceNode(n);
     return n;
 }
Esempio n. 42
0
 /// <summary>
 /// Serialize literal types using either "S" or "G" formatting, depending on the option which has been set.
 /// </summary>
 protected override QilNode VisitLiteralType(QilLiteral value)
 {
     this.writer.WriteString(((XmlQueryType)value).ToString((this.options & Options.TypeInfo) != 0 ? "G" : "S"));
     return(value);
 }
Esempio n. 43
0
 /// <summary>
 /// Generate code for QilNodeType.LiteralString.
 /// </summary>
 protected override QilNode VisitLiteralString(QilLiteral ndStr)
 {
     _helper.Emit(OpCodes.Ldstr, (string)ndStr);
     _iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);
     return ndStr;
 }
Esempio n. 44
0
 protected virtual QilNode VisitLiteralObject(QilLiteral n)
 {
     return(VisitChildren(n));
 }
Esempio n. 45
0
 protected override QilNode VisitLiteralType(QilLiteral n) { return NoReplace(n); }