2 using TypeSystem.Operations;
7 using System.Collections.Generic;
8 using TypeSystem.Constraints;
9 namespace TypeSystem.Operations {
51 this.rightOperand = rightOperand;
53 this.methodAnalyzed = methodAnalyzed;
54 this.unification = unification;
55 this.actualImplicitObject = actualImplicitObject;
56 this.location = location;
61 public override object Exec(
ArrayType leftOperand,
object arg) {
73 if (leftOperand.
Unify(
this.rightOperand,
this.unification,
new List<Pair<TypeExpression, TypeExpression>>()))
76 return ReportError(leftOperand);
78 return ReportError(leftOperand);
84 public override object Exec(
BoolType leftOperand,
object arg) {
91 return this.op == AssignmentOperator.Assign
92 ? rightOperand.AcceptOperation(PromotionOperation.Create(leftOperand, this.op, this.methodAnalyzed, this.location), arg)
93 : ReportError(leftOperand);
100 public override object Exec(
ClassType leftOperand,
object arg) {
108 if ( this.rightOperand.AcceptOperation(
PromotionOperation.
Create(leftOperand,
this.op,
this.methodAnalyzed,
this.location), arg) == null )
116 if (fieldType != null)
117 this.rightOperand = fieldType.FieldTypeExpression;
118 if (leftOperand.
Unify(
this.rightOperand,
this.unification,
new List<Pair<TypeExpression, TypeExpression>>())) {
119 leftOperand.ValidTypeExpression =
false;
123 ErrorManager.Instance.NotifyError(
new OperationNotAllowedError(this.op.ToString(), leftOperand.FullName, rightOperand.FullName, this.location));
130 #region ClassTypeProxy = ...
131 public override object Exec(
ClassTypeProxy leftOperand,
object arg) {
138 return leftOperand.RealType.AcceptOperation(
this, arg);
144 public override object Exec(
CharType leftOperand,
object arg) {
152 return rightOperand.AcceptOperation(PromotionOperation.Create(leftOperand, this.op, this.methodAnalyzed, this.location), arg);
166 return rightOperand.AcceptOperation(PromotionOperation.Create(leftOperand, this.op, this.methodAnalyzed, this.location), arg);
171 #region FieldType = ...
172 public override object Exec(
FieldType leftOperand,
object arg) {
185 ClassType.IsConcreteType(this.actualImplicitObject) == null)
189 while (!(found = (leftOperand.
MemberInfo.
Class == methodSuperClass)) && methodSuperClass != null)
190 methodSuperClass = methodSuperClass.BaseClass;
197 if (thisType == null)
201 thisType = TypeExpression.As<
ClassType>(field.FieldTypeExpression);
204 if (thisType != null)
208 thisType = thisType.BaseClass;
210 if (thisType != null)
216 this.methodAnalyzed.ValidTypeExpression =
false;
227 return leftOperand.FieldTypeExpression;
235 leftOperand.FieldTypeExpression.AcceptOperation(
238 this.location), arg);
245 leftOperand.FieldTypeExpression.AcceptOperation(
247 this.actualImplicitObject, this.location), arg);
254 #region InterfaceType = ...
255 public override object Exec(
InterfaceType leftOperand,
object arg) {
265 return rightOperand.AcceptOperation(PromotionOperation.Create(leftOperand, this.op, this.methodAnalyzed, this.location), arg);
267 return ReportError(leftOperand);
280 return rightOperand.AcceptOperation(PromotionOperation.Create(leftOperand, this.op, this.methodAnalyzed, this.location), arg);
284 #region NullType = ...
285 public override object Exec(
NullType leftOperand,
object arg) {
291 return op == AssignmentOperator.Assign ? this.rightOperand : ReportError(leftOperand);
296 #region PropertyType = ...
297 public override object Exec(
PropertyType leftOperand,
object arg) {
310 return leftOperand.PropertyTypeExpression.AcceptOperation(
new AssignmentOperation(this.rightOperand, this.op, null, this.unification, this.actualImplicitObject, this.location), arg);
318 #region StringType = ...
319 public override object Exec(
StringType leftOperand,
object arg) {
326 return rightOperand.AcceptOperation(PromotionOperation.Create(leftOperand, this.op, this.methodAnalyzed, this.location), arg);
335 #region TypeExpression = ...
344 return ReportError(leftOperand);
350 #region TypeVariable = ...
351 public override object Exec(TypeVariable leftOperand,
object arg) {
360 return rightOperand.AcceptOperation(PromotionOperation.Create(leftOperand, this.op, this.methodAnalyzed, this.location), arg);
362 if (leftOperand.addToMyEquivalenceClass(rightOperand,
this.unification,
new List<Pair<TypeExpression, TypeExpression>>()))
365 ErrorManager.Instance.NotifyError(
new OperationNotAllowedError(this.op.ToString(), leftOperand.FullName, rightOperand.FullName, this.location));
372 #region UnionType = ...
373 public override object Exec(
UnionType leftOperand,
object arg) {
383 leftOperand.TypeSet.Add(rightOperand);
388 return ReportError(leftOperand);
Location location
The location (file, line, column) of text being analyzed.
Dictionary< string, AccessModifier > Fields
Gets the field list
override string FullName
The full name in type variables is calculated just in time
Represents a error produced when tries to make an operation not allowed for the specified type...
Representa an array type.
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.
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
TypeExpression rightOperand
The expression to assignate to the first operrand
override object ReportError(TypeExpression tE)
Represents a interface type.
Represent a character type.
string MemberIdentifier
Gets the attribute name
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...
Abstract class that represents all different types.
Represents a generic type expression
Represents a proxy of a class type. It implements the unfold operatations of theoretical type systes...
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...
AccessModifier MemberInfo
Gets or sets the attribute information of method type
Represent a integer type.
Represents a error produced when an property without write permisses is assigned a value...
SortOfUnification unification
Kind of unification to use: Equivalent, Incremental and Override.
Represents a double type.
override bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
This method unifies two type expressions (this and te)
override object Exec(TypeExpression leftOperand, object arg)
This method never would be called. Is point of double dispatcher. But the dispatch is done with equal...
Represents a error produced when the attribute identifier is not defined.
TypeExpression FieldTypeExpression
Gets the field type.
virtual bool IsDynamic
Indicates if the type has been set as dynamic
Implements Double dispatcher Pattern. The class encapsulates encapsulates all it's needed to perform ...
It represents constraints of the form: alpha := beta, being alpha a field type
Modifier
Indicates differents modifiers to use in class (only public, internal or static), fields or methods...
Representa a property type.
UserType Class
Gets or sets the class type reference
Representa a method type.
override object Exec(DoubleType leftOperand, object arg)
Performs an assigment operation between a DoubleType type and the typeExpression stored in this...
override object AcceptOperation(TypeSystemOperation op, object arg)
TypeExpression actualImplicitObject
Only suitable when the assignment is executed as a constraint of a method call. In that case...
IList< TypeExpression > TypeSet
Gets the list of type expressions
TypeExpression Substitution
Gets the substitution; null if it does not exist
AssignmentOperator op
The kind of assignment to perform. That is, =, +=, -=,... etc
AccessModifier MemberInfo
Gets or sets the attribute information of method type
TypeExpression PropertyTypeExpression
Gets the property type.
MethodType methodAnalyzed
The actual method being analysed.
override bool HasTypeVariables()
To know if the type expression has some type variables and requieres unification The default implemen...
override bool Unify(TypeExpression te, SortOfUnification unification, IList< Pair< TypeExpression, TypeExpression >> previouslyUnified)
Returns a value thdat indicates a promotion level.
AssignmentOperator
Assignment binary operators
override object Exec(IntType leftOperand, object arg)
Performs an assigment operation between a IntType type and the typeExpression stored in this...
override bool HasTypeVariables()
To know if the type expression has some type variables and requieres unification The default implemen...