23 using System.Collections.Generic;
27 using ErrorManagement;
29 using TypeSystem.Operations;
31 namespace TypeSystem.Constraints {
62 get {
return this.actualImplicitObject; }
69 get {
return this.parameters; }
84 : base(firstOperand, location) {
85 this.actualImplicitObject = actualImplicitObject;
86 this.parameters = parameters;
87 this.sortOfUnification = sortOfUnification;
100 : base(firstOperand, returnType, location) {
101 this.actualImplicitObject = actualImplicitObject;
102 this.parameters = parameters;
103 this.sortOfUnification = sortOfUnification;
107 #region BuildTypeExpressionString()
110 sb.AppendFormat(
"{0}:={1}({2}", this.ReturnType.FullName, this.FirstOperand.FullName, this.ActualImplicitObject.FullName);
112 sb.AppendFormat(
",{0}", parameter.FullName);
114 return sb.ToString();
118 #region CloneTypeVariables()
119 public override Constraint CloneTypeVariables(IDictionary<TypeVariable, TypeVariable> typeVariableMappings, IList<EquivalenceClass> equivalenceClasses) {
128 TypeExpression newFirstOperand = this.FirstOperand.CloneTypeVariables(typeVariableMappings, equivalenceClasses,
new List<ClassType>());
130 if (this.ActualImplicitObject != null)
131 newActualImplicitObject = this.ActualImplicitObject.CloneTypeVariables(typeVariableMappings, equivalenceClasses,
new List<ClassType>());
134 for (
int i = 0; i < this.parameters.Length; i++)
135 newParameters[i] = this.parameters[i].CloneTypeVariables(typeVariableMappings, equivalenceClasses,
new List<ClassType>());
136 return new ParenthesisConstraint(newFirstOperand, newActualImplicitObject, newParameters, newReturnType, this.sortOfUnification, this.
Location);
154 FieldType implicitObjectAsField = TypeExpression.As<
FieldType>(this.actualImplicitObject);
157 if (implicitObjectAsField != null) {
158 implicitObject = implicitObjectAsField.FieldTypeExpression;
159 implicitObjectAsClass = TypeExpression.As<
ClassType>(implicitObjectAsField.FieldTypeExpression);
162 implicitObjectAsClass = TypeExpression.As<ClassType>(this.actualImplicitObject);
164 if (ClassType.IsConcreteType(actualImplicitObject) != null && implicitObjectAsClass != null)
170 TypeExpression result = (TypeExpression)this.FirstOperand.AcceptOperation(
new ParenthesisOperation(implicitObject, this.Parameters, methodAnalyzed, unification, this.
Location), null);
171 if (result == null && showInvocationMessage) {
176 this.ReturnType.Unify(result, SortOfUnification.Equivalent,
new List<Pair<TypeExpression, TypeExpression>>());
177 this.ReturnType.ValidTypeExpression = this.ValidTypeExpression =
false;
178 return this.ReturnType;
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...
Represents a error produced when a constraint has not been satisfied
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.
It represents constraints of the form: ret := op1(implicitObj, param*) where op1 is a method...
Abstract class that represents all different types.
Represents a generic type expression
System.Text.StringBuilder StringBuilder
bool ConcreteType
Indicates if the class holds a concrete type. Opposite to an abstract type, a concrete type holds the...
override string BuildTypeExpressionString()
Implements Double Dispatch Pattern Role:
Representa a method type.