18 using System.Collections.Generic;
20 using System.Text.RegularExpressions;
23 using ErrorManagement;
25 using TypeSystem.Operations;
27 namespace TypeSystem {
56 get {
return this.arrayType; }
66 this.isDynamic = value;
67 if (this.arrayType != null)
68 this.arrayType.IsDynamic = value;
80 this.arrayType = type;
81 this.fullName = type.FullName +
"[]";
82 string introspectiveName = type.GetType().
FullName +
"[]";
93 #region BuildTypeExpressionString()
95 if (this.ValidTypeExpression)
return this.typeExpression;
96 if (depthLevel <= 0)
return this.FullName;
98 this.typeExpression = this.typeExpression = String.Format(
"Array({0})", this.arrayType.BuildTypeExpressionString(depthLevel - 1));
99 this.ValidTypeExpression =
true;
104 #region BuildFullName()
109 this.fullName = this.arrayType.fullName +
"[]";
115 #region Assignment() ANULAda
146 #region Bracket() ANULADA
167 #region AsClassType()
178 #region Equivalent() ANULADA
201 #region Relational() ANULADA
229 #region PromotionLevel() ANULADA
257 #region Equals&GetHashCode()
258 public override bool Equals(
object obj) {
260 if (parameter == null)
262 if (parameter ==
this)
264 return this.arrayType.Equals(parameter.arrayType);
267 return this.FullName.GetHashCode();
283 Pair<TypeExpression, TypeExpression> pair =
new Pair<TypeExpression, TypeExpression>(
this, te);
284 if (previouslyUnified.Contains(pair))
286 previouslyUnified.Add(pair);
288 bool success =
false;
291 success = this.arrayType.Unify(at.arrayType, unification, previouslyUnified);
293 TypeVariable typeVariable = (TypeVariable)te;
296 success = typeVariable.Unify(
this, unification, previouslyUnified);
299 success = this.Unify(typeVariable.Substitution, unification, previouslyUnified);
300 else success =
false;
303 else if (te is UnionType)
304 success = te.Unify(
this, unification, previouslyUnified);
306 this.ValidTypeExpression =
false;
307 te.ValidTypeExpression =
false;
312 #region HasTypeVariables()
320 return this.hasTypeVariablesCache;
321 bool toReturn = this.arrayType.HasTypeVariables();
322 this.validHasTypeVariables =
true;
323 return this.hasTypeVariablesCache = toReturn;
340 IList<EquivalenceClass> equivalenceClasses =
new List<EquivalenceClass>();
347 foreach (EquivalenceClass equivalenceClass
in equivalenceClasses)
348 equivalenceClass.UpdateEquivalenceClass(typeVariableMappings);
349 newArrayType.ValidTypeExpression =
false;
355 #region CloneTypeVariables()
356 public override TypeExpression CloneTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<EquivalenceClass> equivalenceClasses, IList<ClassType> clonedClasses) {
369 ArrayType newType = (
ArrayType)this.MemberwiseClone();
370 newType.arrayType = newType.arrayType.CloneTypeVariables(typeVariableMappings, equivalenceClasses, clonedClasses);
371 newType.ValidTypeExpression =
false;
377 #region UpdateEquivalenceClass()
378 public override void UpdateEquivalenceClass(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<TypeExpression> previouslyUpdated) {
386 if (previouslyUpdated.Contains(
this))
388 previouslyUpdated.Add(
this);
393 this.arrayType.UpdateEquivalenceClass(typeVariableMappings, previouslyUpdated);
394 this.ValidTypeExpression =
false;
398 #region ReplaceTypeVariables()
399 public override void ReplaceTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings) {
405 TypeVariable arrayTypeVariable = this.arrayType as TypeVariable;
406 if (arrayTypeVariable == null) {
411 if (typeVariableMappings.ContainsKey(arrayTypeVariable))
412 this.arrayType = typeVariableMappings[arrayTypeVariable];
413 this.ValidTypeExpression =
false;
420 internal override TypeExpression Clone(IDictionary<int, TypeVariable> clonedTypeVariables, IList<EquivalenceClass> equivalenceClasses, MethodType methodAnalyzed) {
433 ArrayType newType = (
ArrayType)this.MemberwiseClone();
434 newType.arrayType = newType.arrayType.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
435 newType.ValidTypeExpression =
false;
452 return this.arrayType.ILType() +
"[]";
457 #region IsValueType()
override bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
override string BuildTypeExpressionString(int depthLevel)
Returns the type expression The maximum depth of recursion to construct type expressions
override object AcceptOperation(TypeSystemOperation op, object arg)
Representa an array type.
override string ILType()
Gets the string type to use in IL code.
override void ReplaceTypeVariables(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
Replaces type variables substituting the old type variables for the new ones.
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...
override void BuildFullName()
Creates/Updates the full name of the type expression
override bool Equals(object obj)
Check if the type can make an relational operation.
Abstract class that represents all different types.
Represents a generic type expression
virtual void ReplaceTypeVariables(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
Replaces type variables substituting the old type variables for the new ones.
virtual string FullName
Gets the full name of the type Note: WriteType expression is the longest recursive representation of ...
override int GetHashCode()
abstract bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
override bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
This method unifies two type expressions (this and te)
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...
TypeExpression ArrayTypeExpression
Gets the array type.
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...
override bool IsDynamic
Indicates if the type has been set as dynamic
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...
TypeExpression Substitution
Gets the substitution; null if it does not exist
override TypeExpression CloneType(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
This method creates a new class type, creating new type variables for each field. It these type varia...
override ClassType AsClassType()
Represent a type as a class. It is mainly used to obtain the BCL representation of types (string=Stri...
override bool HasTypeVariables()
To know if the type expression has some type variables and requieres unification The default implemen...
ArrayType(TypeExpression type)
Constructor of ArrayType