Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GenericDeclaration.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 
5 namespace SiliconStudio.Shaders.Ast
6 {
7  /// <summary>
8  /// A generic declaration. This is used internally to identify a generic declaration.
9  /// </summary>
11  {
12  /// <summary>
13  /// Initializes a new instance of the <see cref="GenericDeclaration"/> class.
14  /// </summary>
16  {
17  }
18 
19  /// <summary>
20  /// Initializes a new instance of the <see cref="GenericDeclaration"/> class.
21  /// </summary>
22  /// <param name="name">The name.</param>
23  /// <param name="holder">The holder.</param>
24  /// <param name="index">The index.</param>
25  /// <param name="isUsingBase">if set to <c>true</c> [is using base].</param>
26  public GenericDeclaration(Identifier name, IGenerics holder, int index, bool isUsingBase)
27  {
28  Name = name;
29  Holder = holder;
30  Index = index;
31  IsUsingBase = isUsingBase;
32  }
33 
34  /// <summary>
35  /// Gets or sets the name of this declaration
36  /// </summary>
37  /// <value>
38  /// The name.
39  /// </value>
40  public Identifier Name { get; set; }
41 
42  /// <summary>
43  /// Gets or sets the holder.
44  /// </summary>
45  /// <value>
46  /// The holder.
47  /// </value>
48  public IGenerics Holder { get; set; }
49 
50  /// <summary>
51  /// Gets or sets the index.
52  /// </summary>
53  /// <value>
54  /// The index.
55  /// </value>
56  public int Index { get; set; }
57 
58  /// <summary>
59  /// Gets or sets a value indicating whether this instance is using base.
60  /// </summary>
61  /// <value>
62  /// <c>true</c> if this instance is using base; otherwise, <c>false</c>.
63  /// </value>
64  public bool IsUsingBase { get; set; }
65 
66  public bool Equals(GenericDeclaration other)
67  {
68  if (ReferenceEquals(null, other)) return false;
69  if (ReferenceEquals(this, other)) return true;
70  return Equals(other.Name, Name) && Equals(other.Holder, Holder) && other.Index == Index && other.IsUsingBase.Equals(IsUsingBase);
71  }
72 
73  public override bool Equals(object obj)
74  {
75  if (ReferenceEquals(null, obj)) return false;
76  if (ReferenceEquals(this, obj)) return true;
77  if (obj.GetType() != typeof(GenericDeclaration)) return false;
78  return Equals((GenericDeclaration)obj);
79  }
80 
81  public override int GetHashCode()
82  {
83  unchecked
84  {
85  int result = Name.GetHashCode();
86  result = (result * 397) ^ Holder.GetHashCode();
87  result = (result * 397) ^ Index;
88  result = (result * 397) ^ IsUsingBase.GetHashCode();
89  return result;
90  }
91  }
92  }
93 }
IGenerics Holder
Gets or sets the holder.
GenericDeclaration(Identifier name, IGenerics holder, int index, bool isUsingBase)
Initializes a new instance of the GenericDeclaration class.
GenericDeclaration()
Initializes a new instance of the GenericDeclaration class.
A generic declaration. This is used internally to identify a generic declaration. ...
An interface used by generic definitions and instance.
Definition: IGenerics.cs:10
Abstract node.
Definition: Node.cs:15
Identifier Name
Gets or sets the name of this declaration
Toplevel interface for a declaration.
Definition: IDeclaration.cs:8