Beispiel #1
0
 public static bool TryGetNumberLiteral(string value, out ILiteral literal)
 {
     if (long.TryParse(value, out long lng))
     {
         literal = new IntegerLiteral(lng);
         return(true);
     }
     else if (double.TryParse(value, out double dbl))
     {
         literal = new FloatLiteral(dbl);
         return(true);
     }
     literal = null;
     return(false);
 }
 public void Visit(IntegerLiteral op)
 {
     if (op.Value <= int.MaxValue && op.Value >= int.MinValue)
     {
         var i = (int)op.Value;
         WriteEncoded(_context.Format(i));
     }
     else if (_version.OnlySupportsV2OrV3())
     {
         WriteEncoded(_context.Format(op.Value) + "L");
     }
     else
     {
         WriteEncoded(_context.Format(op.Value));
     }
 }
Beispiel #3
0
 public virtual void Visit(IntegerLiteral op)
 {
     Writer.Write(Context.Format(op.Value));
 }
 public virtual void Visit(IntegerLiteral op)
 {
 }
 public void Visit(IntegerLiteral op)
 {
     _conditionWriter.WriteElementString("constant", _context.Format(op.Value));
 }
 public virtual IExpression Clone(IntegerLiteral op)
 {
     return(new IntegerLiteral(op.Value));
 }
 void IExpressionVisitor.Visit(IntegerLiteral op)
 {
     _clone = Clone(op);
 }
Beispiel #8
0
        public static bool TryGetLiteral(object value, out ILiteral literal)
        {
            literal = null;
            if (value is bool b)
            {
                literal = new BooleanLiteral(b);
            }
            else if (value is byte by)
            {
                literal = new IntegerLiteral(by);
            }
            else if (value is sbyte sb)
            {
                literal = new IntegerLiteral(sb);
            }
            else if (value is short sh)
            {
                literal = new IntegerLiteral(sh);
            }
            else if (value is ushort us)
            {
                literal = new IntegerLiteral(us);
            }
            else if (value is int i)
            {
                literal = new IntegerLiteral(i);
            }
            else if (value is uint ui)
            {
                literal = new IntegerLiteral(ui);
            }
            else if (value is long l)
            {
                literal = new IntegerLiteral(l);
            }
            else if (value is ulong ul)
            {
                literal = new IntegerLiteral((long)ul);
            }
            else if (value is float f)
            {
                literal = new FloatLiteral(f);
            }
            else if (value is double d)
            {
                literal = new FloatLiteral(d);
            }
            else if (value is DateTime dt)
            {
                literal = new DateTimeLiteral(dt);
            }
            else if (value is Guid g)
            {
                literal = new StringLiteral(g.ToArasId());
            }
            else if (value is string str)
            {
                literal = new StringLiteral(str);
            }
            else
            {
                return(false);
            }

            return(true);
        }