The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
AccessModifier.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: AccessModifier.cs //
6 // Authors: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Francisco Ortin - francisco.ortin@gmail.com //
8 // Description: //
9 // Association Class between ClassType and MethodType (or Fields). //
10 // Represents the access modifier infomation about a concrete attribute and //
11 // its class. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 22-10-2006 //
14 // Modification date: 18-04-2007 //
16 
17 using System;
18 using System.Diagnostics;
19 using System.Collections.Generic;
20 using System.Text;
21 
22 using AST;
23 using TypeSystem.Operations;
24 //viSto0
25 namespace TypeSystem
26 {
27  #region Modifier
28 
32  public enum Modifier
33  {
34  Public = 2,
35  Protected = 4,
36  Internal = 8,
37  Private = 16,
38  Static = 32,
39  Abstract = 64,
40  New = 128,
41  Override = 256,
42  Virtual = 512,
44  CanRead = 1024,
45  CanWrite = 2048,
46  }
47 
48  #endregion
49 
56  public class AccessModifier : ICloneable
57  {
58  #region Fields
59 
63  private UserType classType;
64 
68  private IMemberType type;
69 
73  private List<Modifier> modifierList;
74 
78  private Modifier modifierMask;
79 
83  private string id;
84 
85  #endregion
86 
87  #region Properties
88 
92  public TypeExpression Type
93  {
94  get
95  {
96  System.Diagnostics.Debug.Assert(type==null || type is IMemberType, "The type must be a TypeExpression");
97  return (TypeExpression)type;
98  }
99  set
100  {
101  System.Diagnostics.Debug.Assert(value is IMemberType, "The type must implement IMemberType");
102  type = (IMemberType)value;
103  }
104  }
105 
109  public UserType Class
110  {
111  get { return this.classType; }
112  set { this.classType = value; }
113  }
114 
118  public string MemberIdentifier
119  {
120  get { return this.id; }
121  }
122 
126  public List<Modifier> Modifiers
127  {
128  get { return this.modifierList; }
129  }
130 
134  public Modifier ModifierMask
135  {
136  get { return this.modifierMask; }
137  }
138 
139  #endregion
140 
141  #region Constructor
142 
150  public AccessModifier(List<Modifier> mods, string idMember, IMemberType memberType, bool interfaceMember)
151  {
152  for (int i = 0; i < mods.Count; i++)
153  {
154  this.modifierMask |= mods[i];
155  }
156 
157  if (!interfaceMember)
158  {
159  if ((this.modifierMask & Modifier.AccessLevel) == 0)
160  {
161  mods.Add(Modifier.Private);
162  this.modifierMask |= Modifier.Private;
163  }
164  }
165 
166  this.modifierList = mods;
167  this.type = memberType;
168  this.id = idMember;
169  }
170  #endregion
171 
172  #region Dispatcher
173  //public override object AcceptOperation(TypeSystemOperation op) { return op.AcceptOperation(this); }
174  #endregion
175 
176  #region hasModifier()
177  public bool hasModifier(Modifier mod)
183  {
184  if ((this.modifierMask & mod) != 0)
185  return true;
186 
187  for (int i = 0; i < this.modifierList.Count; i++)
188  if ((this.modifierList[i] & mod) != 0)
189  return true;
190  return false;
191  }
192  #endregion
193 
194  #region Clone()
195  public Object Clone()
196  {
197  return this.MemberwiseClone();
198  }
199  #endregion
200  }
201 }
Modifier ModifierMask
Gets the modifier information
string MemberIdentifier
Gets the attribute name
AccessModifier(List< Modifier > mods, string idMember, IMemberType memberType, bool interfaceMember)
Constructor of AccessModifier
bool hasModifier(Modifier mod)
To know if a modifier is supported
Abstract class that represents all different types.
Modifier
Indicates differents modifiers to use in class (only public, internal or static), fields or methods...
UserType Class
Gets or sets the class type reference
List< Modifier > Modifiers
Gets the modifiers of the element
Association Class between ClassType and MethodType (or Fields). Represents the access modifier inform...
TypeExpression Type
Gets or sets the attribute type expression
Represents a class or interface type.
Definition: UserType.cs:31
Representa a class attribute (fields or methods).
Definition: IMemberType.cs:32