Inference/src/TypeSystem/Operations/BinaryArithmeticalOperation.cs
/// <summary>
/// This method check whether the firstOperand is has fresh varuabkes, in wich case it apply the operation
/// to all the variable in the union
/// </summary>
/// <param name="firstOperand">A UnionType TypeExpression, to operate with the operator and second operand </param>
/// <returns>in this case the TypeExpression associated with the field is valid it returns the result of aplying the operation 
/// with to the Union the operator and second operand, stored in the TypeSystemOperation Object.
/// Null in case the Field does not contain a valid TypeExpression.
/// </returns>
This method check whether the firstOperand is has fresh varuabkes, in wich case it apply the operation
to all the variable in the union
This method check whether the firstOperand is has fresh varuabkes in wich case it apply the operation to all the variable in the union
public override object Exec(UnionType firstOperand, object arg) {
            if (firstOperand.IsFreshVariable() && methodAnalyzed != null) {
                ArithmeticConstraint constraint = new ArithmeticConstraint(firstOperand, secondOperand, binaryOperator, location);
                methodAnalyzed.AddConstraint(constraint);
                return constraint.ReturnType;
            }
            TypeExpression returnType = null;
            foreach (TypeExpression type in firstOperand.TypeSet) {
                TypeExpression ret = (TypeExpression)type.AcceptOperation(ArithmeticalOperation.Create(secondOperand, binaryOperator, methodAnalyzed, !firstOperand.IsDynamic && showErrorMessage, location), arg);
                if (ret == null && !firstOperand.IsDynamic)
                    return null;
                if (ret != null)
                    returnType = UnionType.collect(returnType, ret);
            }
            if (showErrorMessage && firstOperand.IsDynamic && returnType == null)
                ErrorManager.Instance.NotifyError(new NoTypeAcceptsOperation(firstOperand.FullName, this.binaryOperator.ToString(), secondOperand.FullName, location));
            return returnType;
        }
public override object Exec ( UnionType firstOperand , object arg ) { if ( firstOperand . IsFreshVariable ( ) && methodAnalyzed != null ) { ArithmeticConstraint constraint = new ArithmeticConstraint ( firstOperand , secondOperand , binaryOperator , location ) ; methodAnalyzed . AddConstraint ( constraint ) ; return constraint . ReturnType ; } TypeExpression returnType = null ; foreach ( TypeExpression type in firstOperand . TypeSet ) { TypeExpression ret = ( TypeExpression ) type . AcceptOperation ( ArithmeticalOperation . Create ( secondOperand , binaryOperator , methodAnalyzed , ! firstOperand . IsDynamic && showErrorMessage , location ) , arg ) ; if ( ret == null && ! firstOperand . IsDynamic ) return null ; if ( ret != null ) returnType = UnionType . collect ( returnType , ret ) ; } if ( showErrorMessage && firstOperand . IsDynamic && returnType == null ) ErrorManager . Instance . NotifyError ( new NoTypeAcceptsOperation ( firstOperand . FullName , this . binaryOperator . ToString ( ) , secondOperand . FullName , location ) ) ; return returnType ; }
This method check whether the firstOperand is has fresh varuabkes, in wich case it apply the operation
to all the variable in the union
This method check whether the firstOperand is has fresh varuabkes in wich case it apply the operation to all the variable in the union
// * If all the types in typeset generate a constraint, we simply generate one constraint using the whole union type // * A constraint is added to the method analyzed // * If there has been some errors, they have not been shown because the type is dynamic, we show it
in this case the TypeExpression associated with the field is valid it returns the result of aplying the operation
with to the Union the operator and second operand, stored in the TypeSystemOperation Object.
Null in case the Field does not contain a valid TypeExpression.
in this case the TypeExpression associated with the field is valid it returns the result of aplying the operation with to the Union the operator and second operand stored in the TypeSystemOperation Object . Null in case the Field does not contain a valid TypeExpression .
firstOperand
UnionType
A UnionType TypeExpression, to operate with the operator and second operand
A UnionType TypeExpression to operate with the operator and second operand
arg
object