protected internal Primitive(NRefactory.PrimitiveExpression primitiveExpression, IScope scope, INRefcatoryExpressionVisitor visitor) : base(scope, visitor) { _primitiveExpression = primitiveExpression; Value = primitiveExpression.Value; InternalType = Value.GetType(); }
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { PrimitiveExpression o = other as PrimitiveExpression; return(o != null && (this.Value == AnyValue || object.Equals(this.Value, o.Value))); }
void IAstVisitor.VisitPrimitiveExpression(PrimitiveExpression primitiveExpression) { Visit(EnterPrimitiveExpression, LeavePrimitiveExpression, primitiveExpression); }
public virtual S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data) { return(VisitChildren(primitiveExpression, data)); }
public override void VisitCastExpression(CastExpression castExpression) { ParenthesizeIfRequired(castExpression.Expression, InsertParenthesesForReadability ? Primary : Unary); // There's a nasty issue in the C# grammar: cast expressions including certain operators are ambiguous in some cases // "(int)-1" is fine, but "(A)-b" is not a cast. UnaryOperatorExpression uoe = castExpression.Expression as UnaryOperatorExpression; if (uoe != null && !(uoe.Operator == UnaryOperatorType.BitNot || uoe.Operator == UnaryOperatorType.Not)) { if (TypeCanBeMisinterpretedAsExpression(castExpression.Type)) { Parenthesize(castExpression.Expression); } } // The above issue can also happen with PrimitiveExpressions representing negative values: PrimitiveExpression pe = castExpression.Expression as PrimitiveExpression; if (pe != null && pe.Value != null && TypeCanBeMisinterpretedAsExpression(castExpression.Type)) { TypeCode typeCode = Type.GetTypeCode(pe.Value.GetType()); switch (typeCode) { case TypeCode.SByte: if ((sbyte)pe.Value < 0) { Parenthesize(castExpression.Expression); } break; case TypeCode.Int16: if ((short)pe.Value < 0) { Parenthesize(castExpression.Expression); } break; case TypeCode.Int32: if ((int)pe.Value < 0) { Parenthesize(castExpression.Expression); } break; case TypeCode.Int64: if ((long)pe.Value < 0) { Parenthesize(castExpression.Expression); } break; case TypeCode.Single: if ((float)pe.Value < 0) { Parenthesize(castExpression.Expression); } break; case TypeCode.Double: if ((double)pe.Value < 0) { Parenthesize(castExpression.Expression); } break; case TypeCode.Decimal: if ((decimal)pe.Value < 0) { Parenthesize(castExpression.Expression); } break; } } base.VisitCastExpression(castExpression); }
public static Primitive Primitive(NRefactory.PrimitiveExpression primitiveExpression, IScope scope, INRefcatoryExpressionVisitor visitor) { return(new Primitive(primitiveExpression, scope, visitor)); }
protected internal Primitive(NRefactory.PrimitiveExpression primitiveExpression, IScope scope, INRefcatoryExpressionVisitor visitor) : base(scope, visitor) { _primitiveExpression = primitiveExpression; Value = primitiveExpression.Value; InternalType = Value.GetType(); }
public override ConstantExpression VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) { TypeCode typeCode = Type.GetTypeCode(primitiveExpression.Value.GetType()); return(new PrimitiveConstantExpression(typeCode.ToTypeReference(), primitiveExpression.Value)); }
public virtual S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data) { throw new NotImplementedException(); }
public override AstExpression VisitPrimitiveExpression(NRefactory.PrimitiveExpression primitiveExpression, IScope scope) { return(AstExpression.Primitive(primitiveExpression, scope, this)); }