The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
ClassType.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: ClassType.cs //
6 // Authors: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Francisco Ortin - francisco.ortin@gmail.com //
8 // Description: //
9 // Represents a class type. //
10 // Inheritance: UserType. //
11 // Implements Composite pattern [Composite]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 22-10-2006 //
14 // Modification date: 05-06-2007 //
16 //visto
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20 
21 using AST;
22 using TypeSystem.Constraints;
23 using ErrorManagement;
24 using Tools;
25 using TypeSystem.Operations;
26 
27 namespace TypeSystem {
35  public class ClassType : UserType {
36  #region Fields
37 
41  protected ClassType baseClass;
42 
47  protected bool isConcreteType = false;
48 
49  #endregion
50 
51  #region Properties
52 
57  get { return this.baseClass; }
58  }
59 
64  public bool ConcreteType {
65  get { return this.isConcreteType; }
66  set {
67  // * Sets the appropriate value in the hierarchy
68  ClassType klass = this;
69  while (klass != null) {
70  klass.isConcreteType = value;
71  klass = klass.baseClass;
72  }
73  }
74  }
75  #endregion
76 
77  #region Constructors
78 
86  public ClassType(string identifier, string fullName, List<Modifier> modifiers)
87  : base(fullName) {
88  this.name = identifier;
89  this.Modifiers = modifiers;
90  }
91 
96  public ClassType(string name)
97  : base(name) {
98  this.name = name;
99  this.Modifiers = new List<Modifier>();
100  }
101  #endregion
102 
103 
104  #region AddBaseClass()
105  public override void AddBaseClass(ClassType inheritedClass, Location location) {
113  if (this.baseClass == null)
114  this.baseClass = inheritedClass;
115  else
116  ErrorManager.Instance.NotifyError(new MultipleBaseClassError(this.fullName, location));
117  }
118  #endregion
119 
120  #region BuildTypeExpressionString()
121 
125  public override string BuildTypeExpressionString(int depthLevel) {
126  if (this.ValidTypeExpression)
127  return this.typeExpression;
128  if (depthLevel <= 0)
129  return this.FullName;
130  StringBuilder tE = new StringBuilder();
131  // tE: Class(id, modifiers, base, interfaces, members)
132  tE.AppendFormat("Class({0},", this.BuildTypeExpressionString(depthLevel - 1));
133  // modifiers
134  if (this.modifierList.Count != 0) {
135  for (int i = 0; i < this.modifierList.Count - 1; i++) {
136  tE.AppendFormat(" {0} x", this.modifierList[i]);
137  }
138  tE.AppendFormat(" {0}", this.modifierList[this.modifierList.Count - 1]);
139  }
140  tE.Append(", ");
141 
142  // base
143  if (this.baseClass != null)
144  tE.Append(this.baseClass.FullName);
145  tE.Append(", ");
146 
147  // interfaces
148  if (this.interfaceList.Count != 0) {
149  for (int i = 0; i < this.interfaceList.Count - 1; i++) {
150  tE.AppendFormat(" {0} x", this.interfaceList[i].FullName);
151  }
152  tE.AppendFormat(" {0}", this.interfaceList[this.interfaceList.Count - 1].FullName);
153  }
154  tE.Append(",");
155 
156  // members
157  if (this.Members.Count != 0) {
158  Dictionary<string, AccessModifier>.KeyCollection keys = this.Members.Keys;
159  int i = 0;
160  foreach (string key in keys) {
161  tE.Append(this.Members[key].Type.BuildTypeExpressionString(depthLevel - 1));
162  if (i < keys.Count - 1)
163  tE.Append(" x ");
164  i++;
165  }
166  }
167  tE.Append(")");
168  this.ValidTypeExpression = true;
169  return this.typeExpression = tE.ToString();
170  }
171 
172  #endregion
173 
174  // WriteType inference
175 
176  #region Dispatcher
177  public override object AcceptOperation(TypeSystemOperation op, object arg) { return op.Exec(this, arg); }
178  #endregion
179 
180  #region Assignment() ANULADA
181  //public override TypeExpression Assignment(TypeExpression operand, AssignmentOperator op, MethodType methodAnalyzed, SortOfUnification unification,
195  // TypeExpression actualImplicitObject, Location location) {
196  // if (op == AssignmentOperator.Assign) {
197  // if (operand.Promotion(this, op, methodAnalyzed, location) == null)
198  // return null;
199  // if (!this.HasTypeVariables())
200  // return this;
201  // // * If the left expression of the assignment has type variables,
202  // // we must return the concrete type (not the abstract one)
203  // // * Then whe unify the concrete types
204  // FieldType fieldType = TypeExpression.As<FieldType>(operand);
205  // if (fieldType != null)
206  // operand = fieldType.FieldTypeExpression;
207  // if (this.Unify(operand, unification, new List<Pair<TypeExpression, TypeExpression>>())) {
208  // this.ValidTypeExpression = false;
209  // return this;
210  // }
211  // }
212  // ErrorManager.Instance.NotifyError(new OperationNotAllowedError(op.ToString(), this.FullName, operand.FullName, location));
213  // return null;
214  //}
215  #endregion
216 
217  #region Dot() ANULADA
218  //public override TypeExpression Dot(string memberName, MethodType methodAnalyzed, IList<TypeExpression> previousDot, Location loc) {
231  // TypeExpression member = this.Dot(memberName, previousDot);
232  // if (member == null) {
233  // ErrorManager.Instance.NotifyError(new UnknownMemberError(memberName, loc));
234  // return null;
235  // }
236  // if (!validAccess(member)) {
237  // ErrorManager.Instance.NotifyError(new ProtectionLevelError(memberName, loc));
238  // return null;
239  // }
240  // return member;
241  //}
250  //public override TypeExpression Dot(string memberName, IList<TypeExpression> previousDot) {
251  // if (this.Members.ContainsKey(memberName))
252  // return this.Members[memberName].WriteType;
253  // if (this.baseClass != null) // Search in inherit class
254  // return this.baseClass.Dot(memberName, previousDot);
255  // return null;
256  //}
262  public bool validAccess(TypeExpression member) {
263  // * Union or Intersection type
264  IList<TypeExpression> typeSet=null;
265  UnionType unionType = member as UnionType;
266  if (member is UnionType)
267  typeSet=((UnionType)member).TypeSet;
268  else if (member is IntersectionType)
269  typeSet=((IntersectionType)member).TypeSet;
270  if (typeSet!=null) {
271  bool anyValid=false;
272  foreach (TypeExpression type in typeSet) {
273  if (!this.validAccess(type) && !member.IsDynamic)
274  return false;
275  else anyValid = true;
276  return anyValid;
277  }
278  }
279  // * Member type
280  IMemberType memberType = member as IMemberType;
281  if (memberType == null || memberType.MemberInfo == null)
282  return false;
283  // * Public or Internal
284  if (memberType.MemberInfo.hasModifier(Modifier.Public) || memberType.MemberInfo.hasModifier(Modifier.Internal))
285  return true;
286  // * Private
287  if (memberType.MemberInfo.hasModifier(Modifier.Private))
288  return (bool)this.AcceptOperation(new EquivalentOperation(memberType.MemberInfo.Class), null);
289  // * Protected
290  return (bool)this.AcceptOperation(new EquivalentOperation(memberType.MemberInfo.Class), null) || this.InheritsFrom(memberType.MemberInfo.Class);
291  }
292  #endregion
293 
294  #region InheritsFrom()
295  public override bool InheritsFrom(UserType superType) {
301  // * A class does not inherit from itself
302  if ((bool)this.AcceptOperation( new EquivalentOperation(superType), null))
303  return false;
304  // * Searches in the base classes
305  ClassType myBase = this.BaseClass;
306  while (myBase != null) {
307  if ((bool)myBase.AcceptOperation(new EquivalentOperation(superType), null))
308  return true;
309  myBase = myBase.BaseClass;
310  }
311  // * Interfaces
312  return base.InheritsFrom(superType);
313  }
314  #endregion
315 
316  #region Parenthesis() ANULADA
317  //public override TypeExpression Parenthesis(TypeExpression actualImplicitObject, TypeExpression[] arguments, MethodType methodAnalyzed,
330  // SortOfUnification activeSortOfUnification, Location loc) {
331  // MethodType method = (MethodType)this.AcceptOperation(DotOperation.Create(this.name, new List<TypeExpression>()));
332  // if (method == null)
333  // return null;
334  // return method.Parenthesis(actualImplicitObject, arguments, methodAnalyzed, activeSortOfUnification, loc);
335  //}
336  #endregion
337 
338  #region AsClassType()
339  public override ClassType AsClassType() {
345  return this;
346  }
347  #endregion
348 
349  // WriteType Promotion
350 
351  #region PromotionLevel()
352 
358  //public override int PromotionLevel(TypeExpression type) {
359  // int aux, less = -1;
360 
361  // // * The same type
362  // if (this == type)
363  // return 0;
364  // // * Equivalent types
365  // if ((bool)this.AcceptOperation(new EquivalentOperation(type)))
366  // return 0;
367 
368  // // * Field type and bounded type variable
369  // FieldType fieldType = TypeExpression.As<FieldType>(type);
370  // if (fieldType != null)
371  // return this.PromotionLevel(fieldType.FieldTypeExpression);
372 
373  // // * WriteType variable
374  // TypeVariable typeVariable = type as TypeVariable;
375  // if (typeVariable != null) {
376  // if (typeVariable.Substitution != null)
377  // // * If the variable is bounded, the promotion is the one of its substitution
378  // return this.PromotionLevel(typeVariable.EquivalenceClass.Substitution);
379  // // * A free variable is complete promotion
380  // return 0;
381  // }
382 
383  // // * Inheritance
384  // if (this.BaseClass == null)
385  // // * Object only promotes to object
386  // return -1;
387  // if ((bool)this.baseClass.AcceptOperation(new EquivalentOperation(type)))
388  // return 1;
389  // else {
390  // aux = this.baseClass.PromotionLevel(type);
391  // if (aux != -1)
392  // return aux + 1;
393  // }
394 
395  // // * Interfaces
396  // if (this.interfaceList.Count != 0) {
397  // for (int i = 0; i < this.interfaceList.Count; i++) {
398  // if ((bool)this.interfaceList[i].AcceptOperation( new EquivalentOperation(type))) {
399  // if ((less > 1) || (less == -1))
400  // less = 1;
401  // }
402  // else {
403  // aux = this.interfaceList[i].PromotionLevel(type);
404  // if (aux != -1) {
405  // if ((less > (aux + 1)) || (less == -1))
406  // less = aux + 1;
407  // }
408  // }
409  // }
410  // }
411  // if (less != -1)
412  // return less;
413 
414  // // * Union type
415  // UnionType unionType = TypeExpression.As<UnionType>(type);
416  // if (unionType != null)
417  // return unionType.SuperType(this);
418 
419  // // * No promotion
420  // return -1;
421  //}
422 
423  #endregion
424 
425  // WriteType Unification
426 
427  #region Unify
428  public override bool Unify(TypeExpression te, SortOfUnification unification, IList<Pair<TypeExpression, TypeExpression>> previouslyUnified) {
436  // * Infinite recursion detection
437  Pair<TypeExpression, TypeExpression> pair = new Pair<TypeExpression, TypeExpression>(this, te);
438  if (previouslyUnified.Contains(pair))
439  return true;
440  previouslyUnified.Add(pair);
441 
442  ClassType ct = te as ClassType;
443  bool success = true;
444  // * Class WriteType
445  if (ct != null) {
446  // * Inheritance is taken into account
447  if ((int)ct.AcceptOperation(new PromotionLevelOperation(this), null) == -1)
448  return false;
449  // * Walk upward in the tree till find the correct class
450  while (!(bool)ct.AcceptOperation( new EquivalentOperation(this), null))
451  ct = ct.baseClass;
452  // * Now we unify the fields
453  foreach (string key in this.Fields.Keys) {
454  FieldType thisField = (FieldType)this.Fields[key].Type,
455  teField = (FieldType)ct.Fields[key].Type;
456  if (thisField.FieldTypeExpression is ClassTypeProxy || teField.FieldTypeExpression is ClassTypeProxy)
457  success = thisField.FieldTypeExpression.FullName.Equals(teField.FieldTypeExpression.FullName);
458  else if (!(thisField.Unify(teField, unification, previouslyUnified)))
459  success = false;
460  if (!success)
461  break;
462  }
463  if (success && this.baseClass != null)
464  // * The same with the base class
465  this.baseClass.Unify(ct.baseClass, unification, previouslyUnified);
466  // * If one of the classes is a concrete type, so it is the other
467  if (success)
468  this.ConcreteType = ct.ConcreteType = this.ConcreteType || ct.ConcreteType;
469  }
470  // * WriteType variable
471  else if (te is TypeVariable) {
472  TypeVariable typeVariable = (TypeVariable)te;
473  if (unification != SortOfUnification.Incremental)
474  // * Incremental is commutative
475  success = typeVariable.Unify(this, unification, previouslyUnified);
476  // * Incremental unification (not commutative)
477  else if (typeVariable.Substitution != null)
478  // * Class(var) should unify to Var=Class(int)
479  success = this.Unify(typeVariable.Substitution, unification, previouslyUnified);
480  else success = false;
481  }
482  // * Union WriteType
483  else if (te is UnionType)
484  success = te.Unify(this, unification, previouslyUnified);
485  // * Class WriteType Proxy
486  else if (te is ClassTypeProxy)
487  success = this.Unify(((ClassTypeProxy)te).RealType, unification, previouslyUnified);
488  else if (te is FieldType)
489  success = this.Unify(((FieldType)te).FieldTypeExpression, unification, previouslyUnified);
490  else success = false;
491  // * Clears the type expression cache
492  this.ValidTypeExpression = false;
493  te.ValidTypeExpression = false;
494  return success;
495  }
496  #endregion
497 
498 
499  #region CloneType()
500  public override TypeExpression CloneType(IDictionary<TypeVariable, TypeVariable> typeVariableMappings) {
510  if (!this.HasTypeVariables())
511  return this;
512  // * We clone the members of the ClassType
513  IList<EquivalenceClass> equivalenceClasses = new List<EquivalenceClass>();
514  UserType newClassType = (UserType)this.CloneTypeVariables(typeVariableMappings, equivalenceClasses, new List<ClassType>());
515  // * For each equivalence class we create a new one,
516  // substituting the old type variables for the new ones
517  // * The substitution is not altered
518  // * Since equivalence classes and type variables have a bidirectional association,
519  // the new equivalence classes will make type variables update their new equivalence classes
520  foreach (EquivalenceClass equivalenceClass in equivalenceClasses)
521  equivalenceClass.UpdateEquivalenceClass(typeVariableMappings);
522  // * The new class type is returned
523  newClassType.ValidTypeExpression = false;
524  return newClassType;
525  }
526  #endregion
527 
528 
529  #region CloneTypeVariables()
530  public override TypeExpression CloneTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<EquivalenceClass> equivalenceClasses, IList<ClassType> clonedClasses) {
541  // * Without type variables, no clone is necessary
542  if (!this.HasTypeVariables())
543  return this;
544  // * Let's check recursion
545  if (!clonedClasses.Contains(this))
546  clonedClasses.Add(this);
547  else // * Recursion
548  return new ClassTypeProxy(this, typeVariableMappings, equivalenceClasses);
549  // * We clone the members of the ClassType
550  ClassType newClassType = new ClassType(this.FullName);
551  newClassType.ConcreteType = this.ConcreteType;
552  newClassType.IsDynamic = this.IsDynamic;
553  Dictionary<string, AccessModifier> oldFields = this.Fields;
554  newClassType.fieldList = new Dictionary<string, AccessModifier>();
555  // * We must create new type variables for fields
556  foreach (KeyValuePair<string, AccessModifier> pair in oldFields) {
557  // * Every type variable is cloned to a new one, adding both to typesVariables,
558  // inserting its equivalence classes in the equivalenceClasses parameter and updating the
559  // typeVariableMappings dictionary (<oldvariable,newVariable>
560  FieldType fieldType = (FieldType)pair.Value.Type.CloneTypeVariables(typeVariableMappings, equivalenceClasses, clonedClasses);
561  fieldType.MemberInfo.Class = newClassType;
562  newClassType.AddMember(pair.Key, fieldType.MemberInfo);
563  }
564  // * We must create new attribute info (access modifiers) but without clonning methods
565  foreach (KeyValuePair<string, AccessModifier> pair in this.Methods) {
566  AccessModifier accesModifier = (AccessModifier)pair.Value.Clone();
567  accesModifier.Class = newClassType;
568  newClassType.AddMember(pair.Key, accesModifier);
569  }
570  // * The same with the base class
571  newClassType.baseClass = (ClassType)this.baseClass.CloneType(typeVariableMappings);
572  newClassType.ValidTypeExpression = false;
573  // * The new class type is returned
574  return newClassType;
575  }
576 
577  #endregion
578 
579  #region UpdateEquivalenceClass()
580  public override void UpdateEquivalenceClass(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<TypeExpression> previouslyUpdated) {
587  // * Checks infinite loops
588  if (previouslyUpdated.Contains(this))
589  return;
590  previouslyUpdated.Add(this);
591 
592  // * Updates the equivalence class
593  if (!this.HasTypeVariables())
594  return;
595  foreach (KeyValuePair<string, AccessModifier> pair in this.fieldList)
596  if (pair.Value.Type.HasTypeVariables())
597  pair.Value.Type.UpdateEquivalenceClass(typeVariableMappings, previouslyUpdated);
598  this.baseClass.UpdateEquivalenceClass(typeVariableMappings, previouslyUpdated);
599  this.ValidTypeExpression = false;
600  }
601  #endregion
602 
603  #region ReplaceTypeVariables()
604  public override void ReplaceTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings) {
610  if (!this.HasTypeVariables())
611  return;
612  foreach (KeyValuePair<string, AccessModifier> pair in this.fieldList)
613  if (pair.Value.Type.HasTypeVariables())
614  pair.Value.Type.ReplaceTypeVariables(typeVariableMappings);
615  this.ValidTypeExpression = false;
616  }
617  #endregion
618 
619  // SSA
620 
621  #region Clone()
622  internal override TypeExpression Clone(IDictionary<int, TypeVariable> clonedTypeVariables, IList<EquivalenceClass> equivalenceClasses, MethodType methodAnalyzed) {
633  //return this.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed, new Dictionary<String, TypeExpression>());
634  if (!this.HasTypeVariables())
635  return this;
636  // * We clone the ClassType object
637  ClassType newClassType = (ClassType)this.MemberwiseClone();
638  // * We clone the fields of the class that has type varrables
639  newClassType.fieldList = new Dictionary<string, AccessModifier>();
640  newClassType.Members = new Dictionary<string, AccessModifier>();
641  foreach (KeyValuePair<string, AccessModifier> pair in this.Fields)
642  {
643  IMemberType newFieldType = null;
644  if (pair.Value.Type is FieldType)
645  newFieldType = (IMemberType)((FieldType)pair.Value.Type).Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
646  else
647  newFieldType = (IMemberType)pair.Value.Type.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
648  AccessModifier newAccessModifier = new AccessModifier(pair.Value.Modifiers, pair.Value.MemberIdentifier, newFieldType, false);
649  newClassType.fieldList[pair.Key] = newAccessModifier;
650  newClassType.Members[pair.Key] = newAccessModifier;
651  }
652  foreach (KeyValuePair<string, AccessModifier> pair in this.Methods)
653  newClassType.Members[pair.Key] = pair.Value;
654  // * Clones the base class
655  if (this.BaseClass.HasTypeVariables())
656  newClassType.baseClass = (ClassType)this.BaseClass.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
657  // * The new class type is returned
658  newClassType.ValidTypeExpression = false;
659  return newClassType;
660  }
661 
662  //TODO: To solve Collections/CG.Var.CustomStack.cs test
663  internal TypeExpression Clone(IDictionary<int, TypeVariable> clonedTypeVariables, IList<EquivalenceClass> equivalenceClasses, MethodType methodAnalyzed, IDictionary<String, TypeExpression> evaluated)
664  {
665  if (!this.HasTypeVariables())
666  return this;
667  // * We clone the ClassType object
668  ClassType newClassType = (ClassType)this.MemberwiseClone();
669  if (evaluated.Keys.Contains(this.FullName))
670  return evaluated[this.FullName];
671  evaluated.Add(this.FullName, newClassType);
672  // * We clone the fields of the class that has type varrables
673  newClassType.fieldList = new Dictionary<string, AccessModifier>();
674  newClassType.Members = new Dictionary<string, AccessModifier>();
675  foreach (KeyValuePair<string, AccessModifier> pair in this.Fields)
676  {
677  IMemberType newFieldType = null;
678  if (pair.Value.Type is FieldType)
679  newFieldType = (IMemberType)((FieldType)pair.Value.Type).Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed, evaluated);
680  else
681  newFieldType = (IMemberType)pair.Value.Type.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
682  AccessModifier newAccessModifier = new AccessModifier(pair.Value.Modifiers, pair.Value.MemberIdentifier, newFieldType, false);
683  newClassType.fieldList[pair.Key] = newAccessModifier;
684  newClassType.Members[pair.Key] = newAccessModifier;
685  }
686  foreach (KeyValuePair<string, AccessModifier> pair in this.Methods)
687  newClassType.Members[pair.Key] = pair.Value;
688  // * Clones the base class
689  if (this.BaseClass.HasTypeVariables())
690  newClassType.baseClass = (ClassType)this.BaseClass.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
691  // * The new class type is returned
692  newClassType.ValidTypeExpression = false;
693  return newClassType;
694  }
695  #endregion
696 
697  // Loop detection
698 
699  #region Equals&GetHashCode()
700  public override bool Equals(object obj) {
704  ClassType parameter = obj as ClassType;
705  if (parameter == null) {
706  ClassTypeProxy proxy = obj as ClassTypeProxy;
707  if (proxy == null)
708  return false;
709  parameter = proxy.RealType;
710  }
711  if (!this.FullName.Equals(parameter.FullName))
712  return false;
713  foreach (KeyValuePair<string, AccessModifier> pair in this.fieldList)
714  if (!pair.Value.Type.FullName.Equals(parameter.fieldList[pair.Key].Type.FullName))
715  return false;
716  return true;
717  }
718  public override int GetHashCode() {
719  return this.FullName.GetHashCode();
720  }
721  #endregion
722 
723  // Helper Methods
724 
725  #region IsConcreteType()
726  public static ClassType IsConcreteType(TypeExpression actualImplicitObject) {
732  TypeVariable typeVariable = actualImplicitObject as TypeVariable;
733  if (typeVariable != null)
734  actualImplicitObject = typeVariable.Substitution;
735  ClassType classType = actualImplicitObject as ClassType;
736  if (classType != null && classType.ConcreteType)
737  return classType;
738  UnionType unionType = actualImplicitObject as UnionType;
739  if (unionType != null && unionType.Count > 0)
740  return IsConcreteType(unionType.TypeSet[0]);
741  return null;
742  }
743  #endregion
744 
745  // Code Generation
746 
747  #region ILType()
748 
753  public override string ILType() {
754  StringBuilder aux = new StringBuilder();
755  aux.AppendFormat("class {0}", this.fullName);
756  return aux.ToString();
757  }
758 
759  #endregion
760 
761  #region IsValueType()
762 
767  public override bool IsValueType()
768  {
769  return false;
770  }
771 
772  #endregion
773 
774  }
775 }
bool validAccess(TypeExpression member)
Validates the correct access to members, taking into account the information hiding level...
Definition: ClassType.cs:262
override void AddBaseClass(ClassType inheritedClass, Location location)
Adds a new inherited type
Definition: ClassType.cs:112
Its operation AcceptOperation() returns an integer value that indicates a promotion level between two...
List< InterfaceType > interfaceList
Represents the identifiers of the interfaces
Definition: UserType.cs:58
int Count
Gets the number of type expressions
Definition: UnionType.cs:50
Dictionary< string, AccessModifier > Fields
Gets the field list
Definition: UserType.cs:82
Representa a union type.
Definition: UnionType.cs:36
override void ReplaceTypeVariables(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
Replaces type variables substituting the old type variables for the new ones.
Definition: ClassType.cs:609
AccessModifier MemberInfo
Gets or sets the attribute information of method type
Definition: IMemberType.cs:38
override int GetHashCode()
Definition: ClassType.cs:718
List< Modifier > modifierList
Stores the modifiers belong to the class type
Definition: UserType.cs:63
This class encapsulates a location in a specific file. Implements an Inmutable pattern. So it can be used in any context, that is his internal fields never change.
Definition: Location.cs:24
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
override void UpdateEquivalenceClass(IDictionary< TypeVariable, TypeVariable > typeVariableMappings, IList< TypeExpression > previouslyUpdated)
Replaces the equivalence class of type variables substituting the old type variables for the new ones...
Definition: ClassType.cs:586
UserType(string identifier)
Constructor of UserType
Definition: UserType.cs:169
static ClassType IsConcreteType(TypeExpression actualImplicitObject)
Tells if the parameter is a concrete class type
Definition: ClassType.cs:731
Dictionary< string, AccessModifier > Methods
Gets the method list
Definition: UserType.cs:96
override TypeExpression CloneType(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
This method creates a new class type, creating new type variables for each field. Methods are not clo...
Definition: ClassType.cs:509
override TypeExpression CloneTypeVariables(IDictionary< TypeVariable, TypeVariable > typeVariableMappings, IList< EquivalenceClass > equivalenceClasses, IList< ClassType > clonedClasses)
Method that clones each type variable of a type expression. Equivalence classes are not cloned (but i...
Definition: ClassType.cs:540
bool hasModifier(Modifier mod)
To know if a modifier is supported
override bool HasTypeVariables()
To know if the type expression has some type variables and requieres unification The default implemen...
Definition: UserType.cs:232
Abstract class that represents all different types.
override bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
Definition: ClassType.cs:767
override ClassType AsClassType()
Check if the type can make a method operation.
Definition: ClassType.cs:344
System.Text.StringBuilder StringBuilder
Definition: CSharpParser.cs:4
virtual string FullName
Gets the full name of the type Note: WriteType expression is the longest recursive representation of ...
No location information is provided within this class, because the exec methods invoked by the proper...
bool isConcreteType
Indicates if the class holds a concrete type. Opposite to an abstract type, a concrete type holds the...
Definition: ClassType.cs:47
Dictionary< string, AccessModifier > fieldList
Represents all class fields.
Definition: UserType.cs:43
string name
Class identifier;
Definition: UserType.cs:73
Dictionary< string, AccessModifier > Members
Gets and sets the attribute list
Definition: UserType.cs:103
bool ConcreteType
Indicates if the class holds a concrete type. Opposite to an abstract type, a concrete type holds the...
Definition: ClassType.cs:64
override bool Equals(object obj)
To check loops in recursive types, proxy must be equal that the classes they represent ...
Definition: ClassType.cs:703
ClassType(string name)
Constructor of ClassType
Definition: ClassType.cs:96
Represents the error occurred when a class has multiple base classes.
string fullName
Represents the full name of the type Note: WriteType expression is the longest recursive representati...
Modifier
Indicates differents modifiers to use in class (only public, internal or static), fields or methods...
override string BuildTypeExpressionString(int depthLevel)
Creates the type expression string.
Definition: ClassType.cs:125
UserType Class
Gets or sets the class type reference
ClassType BaseClass
Gets the base type (null if not exists).
Definition: ClassType.cs:56
IList< TypeExpression > TypeSet
Gets the list of type expressions
Definition: UnionType.cs:57
override string ILType()
Gets the string type to use in IL code.
Definition: ClassType.cs:753
Represents a class type.
Definition: ClassType.cs:35
override object AcceptOperation(TypeSystemOperation op, object arg)
Definition: ClassType.cs:177
Representa an intersection type.
override bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
Returns a value thdat indicates a promotion level.
Definition: ClassType.cs:435
ClassType baseClass
If exists, represents the base class (simple inheritance)
Definition: ClassType.cs:41
Represents a class or interface type.
Definition: UserType.cs:31
override bool InheritsFrom(UserType superType)
Tells if the implicit object is a subtype of the superType
Definition: ClassType.cs:300
ClassType(string identifier, string fullName, List< Modifier > modifiers)
Constructor of ClassType
Definition: ClassType.cs:86
Representa a class attribute (fields or methods).
Definition: IMemberType.cs:32