Inference/src/TypeSystem/Constraints/ArithmeticConstraint.cs
/// <summary>
/// Tries to unify the constraints of a method call
/// </summary>
/// <param name="methodAnalyzed">The method that is being analyzed when the operation is performed.</param>
/// <param name="actualImplicitObject">Only suitable in an assignment constraint. It represents the actual object used to pass the message.</param>
/// <param name="showInvocationMessage">To show the invocation line and column in case an error exists</param>
/// <param name="location">The original location where the constraint has been generated</param>
Tries to unify the constraints of a method call
Tries to unify the constraints of a method call
public override TypeExpression Check(MethodType methodAnalyzed, TypeExpression actualImplicitObject, bool showInvocationMessage,
                        SortOfUnification activeSortOfUnification, Location location) {
            TypeExpression result;
            if (this.IsBinary)
                result= (TypeExpression) this.FirstOperand.AcceptOperation(ArithmeticalOperation.Create(this.SecondOperand, this.BinaryOperator, methodAnalyzed, true, this.Location), null);
            else 
                result = (TypeExpression)this.FirstOperand.AcceptOperation(ArithmeticalOperation.Create(this.UnaryOperator, methodAnalyzed, true, this.Location), null);
            if (result == null && showInvocationMessage) {
                ErrorManager.Instance.NotifyError(new ConstraintError(location));
                return null;
            }
            this.ReturnType.Unify(result, SortOfUnification.Equivalent, new List<Pair<TypeExpression, TypeExpression>>());
            this.ReturnType.ValidTypeExpression = this.ValidTypeExpression = false;
            return this.ReturnType;
        }
public override TypeExpression Check ( MethodType methodAnalyzed , TypeExpression actualImplicitObject , bool showInvocationMessage , SortOfUnification activeSortOfUnification , Location location ) { TypeExpression result ; if ( this . IsBinary ) result = ( TypeExpression ) this . FirstOperand . AcceptOperation ( ArithmeticalOperation . Create ( this . SecondOperand , this . BinaryOperator , methodAnalyzed , true , this . Location ) , null ) ; else result = ( TypeExpression ) this . FirstOperand . AcceptOperation ( ArithmeticalOperation . Create ( this . UnaryOperator , methodAnalyzed , true , this . Location ) , null ) ; if ( result == null && showInvocationMessage ) { ErrorManager . Instance . NotifyError ( new ConstraintError ( location ) ) ; return null ; } this . ReturnType . Unify ( result , SortOfUnification . Equivalent , new List < Pair < TypeExpression , TypeExpression > > ( ) ) ; this . ReturnType . ValidTypeExpression = this . ValidTypeExpression = false ; return this . ReturnType ; }
Tries to unify the constraints of a method call
Tries to unify the constraints of a method call
// * Unary // * If no error exists, we unify the return type variable with the actual result
methodAnalyzed
MethodType
The method that is being analyzed when the operation is performed.
The method that is being analyzed when the operation is performed .
actualImplicitObject
TypeExpression
Only suitable in an assignment constraint. It represents the actual object used to pass the message.
Only suitable in an assignment constraint . It represents the actual object used to pass the message .
showInvocationMessage
bool
To show the invocation line and column in case an error exists
To show the invocation line and column in case an error exists
activeSortOfUnification
SortOfUnification
location
Location
The original location where the constraint has been generated
The original location where the constraint has been generated