Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
RegisterLocation.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;
5 using System.Collections.Generic;
6 
7 namespace SiliconStudio.Shaders.Ast.Hlsl
8 {
9  /// <summary>
10  /// Describe a register location
11  /// </summary>
12  public class RegisterLocation : Qualifier
13  {
14  #region Constructors and Destructors
15 
16  /// <summary>
17  /// Initializes a new instance of the <see cref = "RegisterLocation" /> class.
18  /// </summary>
20  : base("register")
21  {
22  IsPost = true;
23  }
24 
25  /// <summary>
26  /// Initializes a new instance of the <see cref="RegisterLocation"/> class.
27  /// </summary>
28  /// <param name="profile">
29  /// The profile.
30  /// </param>
31  /// <param name="idenfitier">
32  /// The idenfitier.
33  /// </param>
34  public RegisterLocation(Identifier profile, Identifier idenfitier)
35  : base("register")
36  {
37  Profile = profile;
38  Register = idenfitier;
39  IsPost = true;
40  }
41 
42  /// <summary>
43  /// Initializes a new instance of the <see cref="RegisterLocation"/> class.
44  /// </summary>
45  /// <param name="profile">
46  /// The profile.
47  /// </param>
48  /// <param name="idenfitier">
49  /// The idenfitier.
50  /// </param>
51  public RegisterLocation(string profile, Identifier idenfitier)
52  : base("register")
53  {
54  Profile = new Identifier(profile);
55  Register = idenfitier;
56  IsPost = true;
57  }
58 
59  #endregion
60 
61  #region Public Properties
62 
63  /// <summary>
64  /// Gets or sets the profile.
65  /// </summary>
66  /// <value>
67  /// The profile.
68  /// </value>
69  public Identifier Profile { get; set; }
70 
71  /// <summary>
72  /// Gets or sets the register.
73  /// </summary>
74  /// <value>
75  /// The register.
76  /// </value>
77  public Identifier Register { get; set; }
78 
79  #endregion
80 
81  #region Public Methods
82 
83  /// <summary>
84  /// Determines whether the specified <see cref="RegisterLocation"/> is equal to this instance.
85  /// </summary>
86  /// <param name="other">
87  /// The <see cref="RegisterLocation"/> to compare with this instance.
88  /// </param>
89  /// <returns>
90  /// <c>true</c> if the specified <see cref="RegisterLocation"/> is equal to this instance; otherwise, <c>false</c>.
91  /// </returns>
92  public bool Equals(RegisterLocation other)
93  {
94  if (ReferenceEquals(null, other))
95  {
96  return false;
97  }
98 
99  if (ReferenceEquals(this, other))
100  {
101  return true;
102  }
103 
104  return base.Equals(other) && Equals(other.Profile, Profile) && Equals(other.Register, Register);
105  }
106 
107  /// <inheritdoc />
108  public override bool Equals(object obj)
109  {
110  if (ReferenceEquals(null, obj))
111  {
112  return false;
113  }
114 
115  if (ReferenceEquals(this, obj))
116  {
117  return true;
118  }
119 
120  return Equals(obj as RegisterLocation);
121  }
122 
123  /// <inheritdoc />
124  public override IEnumerable<Node> Childrens()
125  {
126  ChildrenList.Clear();
127  if (Profile != null)
128  {
129  ChildrenList.Add(Profile);
130  }
131 
132  ChildrenList.Add(Register);
133  return ChildrenList;
134  }
135 
136  /// <inheritdoc />
137  public override int GetHashCode()
138  {
139  unchecked
140  {
141  int result = base.GetHashCode();
142  result = (result * 397) ^ (Profile != null ? Profile.GetHashCode() : 0);
143  result = (result * 397) ^ (Register != null ? Register.GetHashCode() : 0);
144  return result;
145  }
146  }
147 
148  /// <inheritdoc />
149  public override string DisplayName
150  {
151  get
152  {
153  return Profile == null ? string.Format(": register({0})", Register) : string.Format(": register({0},{1})", Profile, Register);
154  }
155  }
156 
157  #endregion
158 
159  #region Operators
160 
161  /// <summary>
162  /// Implements the operator ==.
163  /// </summary>
164  /// <param name = "left">The left.</param>
165  /// <param name = "right">The right.</param>
166  /// <returns>
167  /// The result of the operator.
168  /// </returns>
169  public static bool operator ==(RegisterLocation left, RegisterLocation right)
170  {
171  return Equals(left, right);
172  }
173 
174  /// <summary>
175  /// Implements the operator !=.
176  /// </summary>
177  /// <param name = "left">The left.</param>
178  /// <param name = "right">The right.</param>
179  /// <returns>
180  /// The result of the operator.
181  /// </returns>
182  public static bool operator !=(RegisterLocation left, RegisterLocation right)
183  {
184  return !Equals(left, right);
185  }
186 
187  #endregion
188  }
189 }
bool Equals(RegisterLocation other)
Determines whether the specified RegisterLocation is equal to this instance.
RegisterLocation(Identifier profile, Identifier idenfitier)
Initializes a new instance of the RegisterLocation class.
RegisterLocation()
Initializes a new instance of the RegisterLocation class.
Identifier Profile
Gets or sets the profile.
RegisterLocation(string profile, Identifier idenfitier)
Initializes a new instance of the RegisterLocation class.
override IEnumerable< Node > Childrens()
Gets the child nodes. An enumeration of child nodes
Identifier Register
Gets or sets the register.