~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/PrimitiveExpression.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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)
 
3
 
 
4
using ICSharpCode.NRefactory.VB.PrettyPrinter;
 
5
using System;
 
6
 
 
7
namespace ICSharpCode.NRefactory.VB.Ast
 
8
{
 
9
        /// <summary>
 
10
        /// Represents a literal value.
 
11
        /// </summary>
 
12
        public class PrimitiveExpression : Expression
 
13
        {
 
14
                public static readonly object AnyValue = new object();
 
15
                
 
16
                TextLocation startLocation;
 
17
                public override TextLocation StartLocation {
 
18
                        get {
 
19
                                return startLocation;
 
20
                        }
 
21
                }
 
22
                
 
23
                int length;
 
24
                public override TextLocation EndLocation {
 
25
                        get {
 
26
                                return new TextLocation(StartLocation.Line, StartLocation.Column + length);
 
27
                        }
 
28
                }
 
29
                
 
30
                public object Value { get; private set; }
 
31
                
 
32
                string stringValue;
 
33
                
 
34
                public string StringValue {
 
35
                        get { return stringValue ?? OutputVisitor.ToVBNetString(this); }
 
36
                }
 
37
                
 
38
                public PrimitiveExpression(object value)
 
39
                {
 
40
                        this.Value = value;
 
41
                }
 
42
                
 
43
                public PrimitiveExpression(object value, string stringValue)
 
44
                {
 
45
                        this.Value = value;
 
46
                        this.stringValue = stringValue;
 
47
                }
 
48
                
 
49
                public PrimitiveExpression(object value, TextLocation startLocation, int length)
 
50
                {
 
51
                        this.Value = value;
 
52
                        this.startLocation = startLocation;
 
53
                        this.length = length;
 
54
                }
 
55
                
 
56
                public PrimitiveExpression(object value, string stringValue, TextLocation startLocation, int length)
 
57
                {
 
58
                        this.Value = value;
 
59
                        this.stringValue = stringValue;
 
60
                        this.startLocation = startLocation;
 
61
                        this.length = length;
 
62
                }
 
63
                
 
64
                public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
 
65
                {
 
66
                        return visitor.VisitPrimitiveExpression(this, data);
 
67
                }
 
68
                
 
69
                protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
 
70
                {
 
71
                        PrimitiveExpression o = other as PrimitiveExpression;
 
72
                        return o != null && (this.Value == AnyValue || object.Equals(this.Value, o.Value));
 
73
                }
 
74
        }
 
75
}