Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
UnaryExpression.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 
6 namespace SiliconStudio.Shaders.Ast
7 {
8  /// <summary>
9  /// A unary expression.
10  /// </summary>
11  public class UnaryExpression : Expression
12  {
13  /// <summary>
14  /// Initializes a new instance of the <see cref="UnaryExpression"/> class.
15  /// </summary>
16  public UnaryExpression()
17  {
18  }
19 
20  /// <summary>
21  /// Initializes a new instance of the <see cref="UnaryExpression"/> class.
22  /// </summary>
23  /// <param name="operator">The @operator.</param>
24  /// <param name="expression">The expression.</param>
25  public UnaryExpression(UnaryOperator @operator, Expression expression)
26  {
27  this.Operator = @operator;
28  this.Expression = expression;
29  }
30 
31  /// <summary>
32  /// Gets or sets the operator.
33  /// </summary>
34  /// <value>
35  /// The operator.
36  /// </value>
37  public UnaryOperator Operator { get; set; }
38 
39  /// <summary>
40  /// Gets or sets the expression.
41  /// </summary>
42  /// <value>
43  /// The expression.
44  /// </value>
45  public Expression Expression { get; set; }
46 
47  /// <inheritdoc/>
48  public override IEnumerable<Node> Childrens()
49  {
50  ChildrenList.Clear();
51  ChildrenList.Add(Expression);
52  return ChildrenList;
53  }
54 
55  /// <inheritdoc/>
56  public override string ToString()
57  {
58  var isPostFix = Operator == UnaryOperator.PostIncrement || Operator == UnaryOperator.PostDecrement;
59  var left = isPostFix ? (object)Expression : Operator.ConvertToString();
60  var right = isPostFix ? Operator.ConvertToString() : (object)Expression;
61  return string.Format("{0}{1}", left, right);
62  }
63  }
64 }
UnaryOperator
Unary operator used in all binary expressions (except assignment expression).
UnaryExpression()
Initializes a new instance of the UnaryExpression class.
override IEnumerable< Node > Childrens()
Gets the child nodes. An enumeration of child nodes
UnaryExpression(UnaryOperator @operator, Expression expression)
Initializes a new instance of the UnaryExpression class.