17 using System.Diagnostics;
18 using System.Collections.Generic;
22 using ErrorManagement;
24 using TypeSystem.Operations;
26 namespace TypeSystem {
87 get {
return this.fullName; }
88 set { this.fullName = value; }
94 internal virtual bool ValidTypeExpression {
100 this.BuildFullName();
101 this.typeExpression = this.fullName;
110 get {
return this.isDynamic; }
111 set { this.isDynamic = value; }
119 this.isDynamic =
false;
137 if (!this.ValidTypeExpression) {
139 this.ValidTypeExpression =
true;
141 return this.typeExpression;
146 #region BuildTypeExpressionString()
152 return this.typeExpression;
156 #region BuildFullName()
168 #region Dot() ANULADA
198 #region Parenthesis() ANULADA
217 #region Bracket() ANULADA
236 #region Assignment() ANULADA
257 #region Arithmetic() ANULADA
295 #region Relational() ANULADA
316 #region Equivalent() ANULADA
332 #region AsClassType()
346 #region PromotionLevel() ANULADA
352 #region Promotion() ANULADA
379 #region Cast() ANULADA
399 #region EqualsForOverload() ANULADA
424 #region HasTypeVariables()
435 #region IsFreshVariable()
445 #region HasFreshVariable()
455 #region HasIntersectionVariable()
481 #region CloneTypeVariables()
482 public virtual TypeExpression CloneTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<EquivalenceClass> equivalenceClasses, IList<ClassType> clonedClasses) {
497 #region UpdateEquivalenceClass()
498 public virtual void UpdateEquivalenceClass(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<TypeExpression> previouslyUpdated) {
509 #region ReplaceTypeVariables()
510 public virtual void ReplaceTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings) {
535 internal virtual TypeExpression Clone(IDictionary<int, TypeVariable> clonedTypeVariables, IList<EquivalenceClass> equivalenceClasses, MethodType methodAnalyzed) {
547 throw new InvalidOperationException(
"The type should implement a Clone method.");
556 public virtual bool Remove(TypeVariable toRemove) {
570 public virtual string ILType() {
575 return this.fullName;
580 #region IsValueType()
599 TypeVariable typeVariable = type as TypeVariable;
600 if (typeVariable != null)
601 type = typeVariable.Substitution;
602 T castType = type as T;
616 return TypeExpression.As<T>(type) != null;
621 System.Diagnostics.Debug.Assert(
true,
"getBCLType called in type expression inconsistence in the program");
virtual bool HasFreshVariable()
To know if it is a type variable with no substitution
virtual bool HasIntersectionVariable()
To know if it is a type variable with no substitution
virtual TypeExpression Freeze()
WriteType variable may change its type's substitution (e.g., field type variables) This method return...
TypeExpression(bool isDynamic)
virtual void BuildFullName()
Creates/Updates the full name of the type expression
bool validHasTypeVariables
To cache the result of the HasTypeVariables method
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
virtual ClassType AsClassType()
Check if the type can make a method operation.
bool validTypeExpression
To implement a type expression cache
Abstract class that represents all different types.
virtual void ReplaceTypeVariables(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
Replaces type variables substituting the old type variables for the new ones.
static bool Is< T >(TypeExpression type)
Tells if a type expression is a type or a type variable unified to a type
virtual bool Remove(TypeVariable toRemove)
When loops are detected, it is necesary to suppress a new extra variable returned in the return type ...
virtual string FullName
Gets the full name of the type Note: WriteType expression is the longest recursive representation of ...
virtual BCLClassType getBCLType()
virtual bool IsFreshVariable()
To know if it is a type variable with no substitution
abstract bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
virtual string BuildTypeExpressionString(int depthLevel)
Returns the type expression The maximum depth of recursion to construct type expressions
bool isDynamic
Indicates if the type has been set as dynamic
virtual 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...
static T As< T >(TypeExpression type)
Returns a concrete type expression from a general one. It takes into accout that it can be a type var...
virtual string ILType()
Gets the type name to use in IL code.
virtual bool IsDynamic
Indicates if the type has been set as dynamic
string fullName
Represents the full name of the type Note: WriteType expression is the longest recursive representati...
virtual bool HasTypeVariables()
To know if the type expression has some type variables and requieres unification The default implemen...
string typeExpression
Represents the type by a debug string Note: WriteType expression is the longest recursive representat...
virtual 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...
const int MAX_DEPTH_LEVEL_TYPE_EXPRESSION
In order to avoid stack overflow in the construction of typeexpression string (ToString), we set a maximum level of depth
override string ToString()
Returns the type expression cached in the typeExpression field. Note: WriteType expression is the lon...
abstract bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
Requires the implicit object to be a subtype of the type parameter
bool hasTypeVariablesCache
The cached value ot the HasTypeVariables method
virtual object AcceptOperation(TypeSystemOperation op, object arg)
virtual TypeExpression CloneType(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
This method creates a new type, creating new type variables for type expression. It these type variab...