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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.VB/Ast/Expressions/UnaryOperatorExpression.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 System;
 
5
using System.Collections.Generic;
 
6
 
 
7
namespace ICSharpCode.NRefactory.VB.Ast
 
8
{
 
9
        /// <summary>
 
10
        /// Operator Expression
 
11
        /// </summary>
 
12
        public class UnaryOperatorExpression : Expression
 
13
        {
 
14
                public readonly static Role<VBTokenNode> OperatorRole = BinaryOperatorExpression.OperatorRole;
 
15
                
 
16
                public UnaryOperatorExpression()
 
17
                {
 
18
                }
 
19
                
 
20
                public UnaryOperatorExpression(UnaryOperatorType op, Expression expression)
 
21
                {
 
22
                        this.Operator = op;
 
23
                        this.Expression = expression;
 
24
                }
 
25
                
 
26
                public UnaryOperatorType Operator {
 
27
                        get;
 
28
                        set;
 
29
                }
 
30
                
 
31
                public VBTokenNode OperatorToken {
 
32
                        get { return GetChildByRole (OperatorRole); }
 
33
                }
 
34
                
 
35
                public Expression Expression {
 
36
                        get { return GetChildByRole (Roles.Expression); }
 
37
                        set { SetChildByRole (Roles.Expression, value); }
 
38
                }
 
39
                
 
40
                public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
 
41
                {
 
42
                        return visitor.VisitUnaryOperatorExpression(this, data);
 
43
                }
 
44
                
 
45
                protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
 
46
                {
 
47
                        UnaryOperatorExpression o = other as UnaryOperatorExpression;
 
48
                        return o != null && this.Operator == o.Operator && this.Expression.DoMatch(o.Expression, match);
 
49
                }
 
50
                
 
51
                public static string GetOperatorSymbol(UnaryOperatorType op)
 
52
                {
 
53
                        switch (op) {
 
54
                                case UnaryOperatorType.Not:
 
55
                                        return "Not";
 
56
                                case UnaryOperatorType.Minus:
 
57
                                        return "-";
 
58
                                case UnaryOperatorType.Plus:
 
59
                                        return "+";
 
60
                                default:
 
61
                                        throw new NotSupportedException("Invalid value for UnaryOperatorType");
 
62
                        }
 
63
                }
 
64
        }
 
65
        
 
66
        public enum UnaryOperatorType
 
67
        {
 
68
                /// <summary>Logical/Bitwise not (Not a)</summary>
 
69
                Not,
 
70
                /// <summary>Unary minus (-a)</summary>
 
71
                Minus,
 
72
                /// <summary>Unary plus (+a)</summary>
 
73
                Plus,
 
74
                /// <summary>AddressOf</summary>
 
75
                AddressOf,
 
76
                /// <summary>Await</summary>
 
77
                Await
 
78
        }
 
79
        
 
80
}