1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
4
using ICSharpCode.NRefactory.VB.PrettyPrinter;
7
namespace ICSharpCode.NRefactory.VB.Ast
10
/// Represents a literal value.
12
public class PrimitiveExpression : Expression
14
public static readonly object AnyValue = new object();
16
TextLocation startLocation;
17
public override TextLocation StartLocation {
24
public override TextLocation EndLocation {
26
return new TextLocation(StartLocation.Line, StartLocation.Column + length);
30
public object Value { get; private set; }
34
public string StringValue {
35
get { return stringValue ?? OutputVisitor.ToVBNetString(this); }
38
public PrimitiveExpression(object value)
43
public PrimitiveExpression(object value, string stringValue)
46
this.stringValue = stringValue;
49
public PrimitiveExpression(object value, TextLocation startLocation, int length)
52
this.startLocation = startLocation;
56
public PrimitiveExpression(object value, string stringValue, TextLocation startLocation, int length)
59
this.stringValue = stringValue;
60
this.startLocation = startLocation;
64
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
66
return visitor.VisitPrimitiveExpression(this, data);
69
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
71
PrimitiveExpression o = other as PrimitiveExpression;
72
return o != null && (this.Value == AnyValue || object.Equals(this.Value, o.Value));