5 using TypeSystem.Constraints;
6 using DynVarManagement;
7 namespace TypeSystem.Operations {
22 this.secondOperand = secondOperand;
23 this.relationalOperator = relationalOperator;
24 this.methodAnalyzed = methodAnalyzed;
25 this.showErrorMessage = showErrorMessage;
26 this.location = location;
30 #region TypeExpression >= this.secondOperand
33 ErrorManager.Instance.NotifyError(
new OperationNotAllowedError(this.relationalOperator.ToString(), firstOperand.FullName, this.secondOperand.fullName, this.location));
38 #region DoubleType >= this.secondOperand
42 return this.secondOperand.
AcceptOperation(
new RelationalOperation(firstOperand, this.relationalOperator, this.methodAnalyzed, this.showErrorMessage, this.location), arg);
46 #region IntType >= this.secondOperand
47 public override object Exec(
IntType firstOperand,
object arg) {
55 #region CharType >= this.secondOperand
59 return this.secondOperand.
AcceptOperation(
new RelationalOperation(firstOperand, this.relationalOperator, this.methodAnalyzed, this.showErrorMessage, this.location), arg);
63 #region String >= this.secondOperand
68 if (this.showErrorMessage) {
69 ErrorManager.Instance.NotifyError(
new TypePromotionError(this.secondOperand.FullName, firstOperand.
FullName,
this.relationalOperator.ToString(), this.location));
73 return ReportError(firstOperand);
77 #region PropertyType >= this.secondOperand
80 return firstOperand.PropertyTypeExpression.AcceptOperation(
this, arg);
85 #region ArrayType >= this.secondOperand
94 && showErrorMessage) {
95 ErrorManager.Instance.NotifyError(
new OperationNotAllowedError(relationalOperator.ToString(), firstOperand.FullName, this.secondOperand.FullName, location));
100 ErrorManager.Instance.NotifyError(
new OperationNotAllowedError(relationalOperator.ToString(), this.secondOperand.FullName, location)); ;
105 #region BoolType >= this.secondOperand
110 if (showErrorMessage) {
115 return ReportError(firstOperand);
119 #region UnionType >= this.secondOperand
125 methodAnalyzed.AddConstraint(constraint);
126 return constraint.ReturnType;
128 bool oneCorrectType =
false;
131 if (ret == null && !firstOperand.
IsDynamic)
134 oneCorrectType =
true;
137 if (showErrorMessage && firstOperand.IsDynamic && !oneCorrectType)
138 ErrorManager.Instance.NotifyError(
new NoTypeAcceptsOperation(firstOperand.FullName, relationalOperator.ToString(), secondOperand.FullName, location));
144 #region TypeVariable >= this.secondOperand
147 DynVarOptions.Instance.AssignDynamism(firstOperand.Substitution, firstOperand.IsDynamic);
148 return firstOperand.Substitution.AcceptOperation(
this, arg);
150 if (methodAnalyzed != null) {
153 methodAnalyzed.AddConstraint(constraint);
154 return constraint.ReturnType;
156 return ReportError(firstOperand);
160 #region FieldType >= this.secondOperand
164 return firstOperand.FieldTypeExpression.AcceptOperation(
this, arg);
169 #region UserType >= this.secondOperand
176 if (this.showErrorMessage)
178 ErrorManager.Instance.NotifyError(
new TypePromotionError(this.secondOperand.FullName, firstOperand.
FullName,
this.relationalOperator.ToString(), this.location));
182 return ReportError(firstOperand);
186 #region Report Errors
190 if (this.showErrorMessage)
191 ErrorManager.Instance.NotifyError(
new OperationNotAllowedError(this.relationalOperator.ToString(), tE.FullName, this.secondOperand.FullName, this.location));
override object Exec(TypeVariable firstOperand, object arg)
override object AcceptOperation(TypeSystemOperation op, object arg)
override object Exec(PropertyType firstOperand, object arg)
Represents a error produced when tries to make an operation not allowed for the specified type...
static DoubleType Instance
Gets the unique instance of DoubleType
override object Exec(DoubleType firstOperand, object arg)
Representa an array type.
RelationalOperator relationalOperator
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...
MethodType methodAnalyzed
TypeExpression secondOperand
override object Exec(UserType firstOperand, object arg)
Represent a character type.
override object Exec(StringType firstOperand, object arg)
Abstract class that represents all different types.
Represents a generic type expression
RelationalOperation(TypeExpression secondOperand, RelationalOperator relationalOperator, MethodType methodAnalyzed, bool showErrorMessage, Location location)
virtual string FullName
Gets the full name of the type Note: WriteType expression is the longest recursive representation of ...
RelationalOperator
Relational binary operators
override object Exec(UnionType firstOperand, object arg)
override object Exec(ArrayType firstOperand, object arg)
Represent a integer type.
Represents a double type.
override object ReportError(TypeExpression tE)
TypeExpression FieldTypeExpression
Gets the field type.
virtual bool IsDynamic
Indicates if the type has been set as dynamic
override object Exec(BoolType firstOperand, object arg)
override object Exec(FieldType firstOperand, object arg)
override bool IsFreshVariable()
To know if it is a type variable with no substitution
Representa a property type.
Representa a method type.
It represents constraints of the form: ret := op1 op op2 where op is an relational operator (== != >=...
static BoolType Instance
Gets the unique instance of BoolType
override object Exec(TypeExpression firstOperand, object arg)
TypeExpression Substitution
Gets the substitution; null if it does not exist
override object Exec(CharType firstOperand, object arg)
TypeExpression PropertyTypeExpression
Gets the property type.
override object Exec(IntType firstOperand, object arg)
Represents a error produced when a dynamic union type has no valid type to be applied an operation ...
Represents a class or interface type.
virtual object AcceptOperation(TypeSystemOperation op, object arg)