Inference/src/TypeSystem/Operations/BinaryArithmeticalOperation.cs
/// <summary>
/// The first Operand is a CharType so the second must be promotable in such way that the whole operation must have sense.
/// Implements a double dispatch pattern.
/// </summary>
/// <param name="firstOperand">an CharType to perform a binary arithmetical operatin with. The second operator must 
/// be promotable to Char, IntType, StringType, or DoubleType</param>
/// <returns>A TypeExpression if the operation makes sense, otherwise if showMessages is true, an error is raised</returns>
The first Operand is a CharType so the second must be promotable in such way that the whole operation must have sense.
Implements a double dispatch pattern.
The first Operand is a CharType so the second must be promotable in such way that the whole operation must have sense . Implements a double dispatch pattern .
public override object Exec(CharType firstOperand, object arg) {
            if ((int)this.secondOperand.AcceptOperation(new PromotionLevelOperation(firstOperand), arg) != -1)
            {
                if (secondOperand is TypeVariable && ((TypeVariable)secondOperand).Substitution == null)
                {
                    if (methodAnalyzed != null)
                    {
                        ArithmeticConstraint constraint = new ArithmeticConstraint(firstOperand, secondOperand,
                                                                                   binaryOperator, location);
                        methodAnalyzed.AddConstraint(constraint);
                        return constraint.ReturnType;
                    }
                }
                return IntType.Instance;
            }
            if (this.binaryOperator.Equals(ArithmeticOperator.Plus) && (bool)this.secondOperand.AcceptOperation(new EquivalentOperation(StringType.Instance), arg))
                return StringType.Instance;
            return this.secondOperand.AcceptOperation(ArithmeticalOperation.Create(firstOperand, this.binaryOperator, this.methodAnalyzed, this.showErrorMessage, this.location), arg);
        }
public override object Exec ( CharType firstOperand , object arg ) { if ( ( int ) this . secondOperand . AcceptOperation ( new PromotionLevelOperation ( firstOperand ) , arg ) != - 1 ) { if ( secondOperand is TypeVariable && ( ( TypeVariable ) secondOperand ) . Substitution == null ) { if ( methodAnalyzed != null ) { ArithmeticConstraint constraint = new ArithmeticConstraint ( firstOperand , secondOperand , binaryOperator , location ) ; methodAnalyzed . AddConstraint ( constraint ) ; return constraint . ReturnType ; } } return IntType . Instance ; } if ( this . binaryOperator . Equals ( ArithmeticOperator . Plus ) && ( bool ) this . secondOperand . AcceptOperation ( new EquivalentOperation ( StringType . Instance ) , arg ) ) return StringType . Instance ; return this . secondOperand . AcceptOperation ( ArithmeticalOperation . Create ( firstOperand , this . binaryOperator , this . methodAnalyzed , this . showErrorMessage , this . location ) , arg ) ; }
The first Operand is a CharType so the second must be promotable in such way that the whole operation must have sense.
The first Operand is a CharType so the second must be promotable in such way that the whole operation must have sense .
// * A constraint is added to the method analyzed
A TypeExpression if the operation makes sense, otherwise if showMessages is true, an error is raised
A TypeExpression if the operation makes sense otherwise if showMessages is true an error is raised
firstOperand
CharType
an CharType to perform a binary arithmetical operatin with. The second operator must
be promotable to Char, IntType, StringType, or DoubleType
an CharType to perform a binary arithmetical operatin with . The second operator must be promotable to Char IntType StringType or DoubleType
arg
object