18 using System.Collections.Generic;
20 using System.Text.RegularExpressions;
23 using ErrorManagement;
24 using TypeSystem.Constraints;
26 using DynVarManagement;
27 using TypeSystem.Operations;
29 namespace TypeSystem {
59 get {
return this.fieldType; }
66 get {
return this.memberInfo; }
68 if (this.memberInfo == null) {
69 this.memberInfo = value;
79 internal override bool ValidTypeExpression {
98 this.fieldType = type;
99 this.fullName = type.fullName;
105 #region BuildTypeExpressionString
111 if (this.ValidTypeExpression)
return this.typeExpression;
113 return this.FullName;
116 if (this.fieldType == null)
118 this.fullName = this.fieldType.FullName;
122 tE.AppendFormat(
"Field({0}, {1},", this.MemberInfo.Class.BuildTypeExpressionString(depthLevel - 1), this.
MemberInfo.
MemberIdentifier);
125 for (
int i = 0; i < this.MemberInfo.Modifiers.Count - 1; i++) {
126 tE.AppendFormat(
" {0} x", this.MemberInfo.Modifiers[i]);
128 tE.AppendFormat(
" {0}", this.MemberInfo.Modifiers[this.MemberInfo.Modifiers.Count - 1]);
133 tE.Append(this.fieldType.BuildTypeExpressionString(depthLevel - 1));
135 this.ValidTypeExpression =
true;
136 return this.typeExpression = tE.ToString();
140 #region BuildFullName()
145 this.fieldType.BuildFullName();
146 this.fullName = this.fieldType.fullName;
156 #region Dot() ANULADA
215 #region Assignment() ANULADA
261 #region Arithmetic() >NUL>C>
296 #region Relational()ANULADA
317 #region PromotionLevl()-->#
318 //public override int PromotionLevel(TypeExpression type) {
329 #region Promotion ANULADA
346 #region Cast() ANULADA
377 bool success = this.fieldType.Unify(ft.fieldType, unification, previouslyUnified);
379 DynVarOptions.Instance.AssignDynamism(
this, ft.isDynamic);
381 this.ValidTypeExpression =
false;
382 te.ValidTypeExpression =
false;
387 return te.Unify(
this, unification, previouslyUnified);
389 return te.Unify(
this, unification, previouslyUnified);
390 if (te.
IsValueType() && unification == SortOfUnification.Equivalent)
391 return te.
Unify(
this, unification, previouslyUnified);
396 #region HasTypeVariables()
404 return this.hasTypeVariablesCache;
405 bool toReturn = this.fieldType.HasTypeVariables();
406 this.validHasTypeVariables =
true;
407 return this.hasTypeVariablesCache = toReturn;
414 return this.hasTypeVariablesCache;
418 toReturn = ((UserType) this.fieldType).HasTypeVariables(evaluated);
420 toReturn = ((ClassTypeProxy)this.fieldType).HasTypeVariables(evaluated);
422 toReturn = this.fieldType.HasTypeVariables();
423 this.validHasTypeVariables =
true;
424 return this.hasTypeVariablesCache = toReturn;
429 #region CloneTypeVariables()
430 public override TypeExpression CloneTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<EquivalenceClass> equivalenceClasses, IList<ClassType> clonedClasses) {
445 accesModifier.Class = this.MemberInfo.Class;
446 accesModifier.Type = fieldType;
447 fieldType.IsDynamic = this.IsDynamic;
448 fieldType.MemberInfo = accesModifier;
449 this.ValidTypeExpression = fieldType.ValidTypeExpression =
false;
454 #region UpdateEquivalenceClass()
455 public override void UpdateEquivalenceClass(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<TypeExpression> previouslyUpdated) {
463 if (previouslyUpdated.Contains(
this))
465 previouslyUpdated.Add(
this);
470 this.fieldType.UpdateEquivalenceClass(typeVariableMappings, previouslyUpdated);
471 this.ValidTypeExpression =
false;
475 #region ReplaceTypeVariables()
476 public override void ReplaceTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings) {
482 TypeVariable fieldTypeVariable = this.fieldType as TypeVariable;
483 if (fieldTypeVariable == null) {
488 if (typeVariableMappings.ContainsKey(fieldTypeVariable))
489 this.fieldType = typeVariableMappings[fieldTypeVariable];
490 this.ValidTypeExpression =
false;
494 #region Equivalent ANULADA
517 FieldType newFieldType = (
FieldType)this.MemberwiseClone();
518 newFieldType.fieldType = this.FieldTypeExpression.Freeze();
519 newFieldType.ValidTypeExpression =
false;
529 internal override TypeExpression Clone(IDictionary<int, TypeVariable> clonedTypeVariables, IList<EquivalenceClass> equivalenceClasses, MethodType methodAnalyzed) {
542 FieldType newFieldType = (
FieldType)this.MemberwiseClone();
543 if (newFieldType.fieldType != null)
544 newFieldType.fieldType = newFieldType.fieldType.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
545 newFieldType.ValidTypeExpression =
false;
549 internal TypeExpression Clone(IDictionary<int, TypeVariable> clonedTypeVariables, IList<EquivalenceClass> equivalenceClasses, MethodType methodAnalyzed, IDictionary<String, TypeExpression> evaluated)
553 FieldType newFieldType = (
FieldType)this.MemberwiseClone();
554 if (newFieldType.fieldType is ClassType)
555 newFieldType.fieldType = ((ClassType)newFieldType.fieldType).Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed, evaluated);
556 else if (newFieldType.fieldType != null)
557 newFieldType.fieldType = newFieldType.fieldType.Clone(clonedTypeVariables, equivalenceClasses, methodAnalyzed);
558 newFieldType.ValidTypeExpression =
false;
572 return this.fieldType.ILType();
577 #region IsValueType()
584 return this.fieldType.IsValueType();
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...
bool HasTypeVariables(IList< String > evaluated)
Represents a error produced when a MethodType has class information and tries to assign other class i...
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...
string MemberIdentifier
Gets the attribute name
bool validTypeExpression
To implement a type expression cache
Abstract class that represents all different types.
override bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
Check if the type can make an assignment operation.
Represents a proxy of a class type. It implements the unfold operatations of theoretical type systes...
System.Text.StringBuilder StringBuilder
AccessModifier MemberInfo
Gets or sets the attribute information of method type
FieldType(TypeExpression type)
Constructor of FieldType
virtual bool IsFreshVariable()
To know if it is a type variable with no substitution
override TypeExpression Freeze()
WriteType equivalence. Tells us if two types are the same
abstract bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
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...
TypeExpression FieldTypeExpression
Gets the field type.
override void ReplaceTypeVariables(IDictionary< TypeVariable, TypeVariable > typeVariableMappings)
Replaces type variables substituting the old type variables for the new ones.
override string BuildTypeExpressionString(int depthLevel)
Creates the type expression string.
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...
override string ILType()
Gets the string type to use in IL code.
override object AcceptOperation(TypeSystemOperation op, object arg)
List< Modifier > Modifiers
Gets the modifiers of the element
override void BuildFullName()
Creates/Updates the full name of the type expression
override bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
Association Class between ClassType and MethodType (or Fields). Represents the access modifier inform...
abstract bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
Requires the implicit object to be a subtype of the type parameter
Represents a class or interface type.
override bool HasTypeVariables()
To know if the type expression has some type variables and requieres unification The default implemen...
Representa a class attribute (fields or methods).