public override object Exec(UnionType firstOperand, object arg) { // * If all the types in typeset generate a constraint, we simply generate one constraint using the whole union type if (firstOperand.IsFreshVariable() && methodAnalyzed != null) { // * A constraint is added to the method analyzed RelationalConstraint constraint = new RelationalConstraint(firstOperand, secondOperand, relationalOperator, location); methodAnalyzed.AddConstraint(constraint); return(constraint.ReturnType); } bool oneCorrectType = false; foreach (TypeExpression type in firstOperand.TypeSet) { TypeExpression ret = (TypeExpression)type.AcceptOperation(new RelationalOperation(secondOperand, relationalOperator, methodAnalyzed, !firstOperand.IsDynamic && showErrorMessage, location), arg); if (ret == null && !firstOperand.IsDynamic) { return(null); } if (ret != null) { oneCorrectType = true; } } // * If there has been some errors, they have not been shown because the type is dynamic, we show it if (showErrorMessage && firstOperand.IsDynamic && !oneCorrectType) { ErrorManager.Instance.NotifyError(new NoTypeAcceptsOperation(firstOperand.FullName, relationalOperator.ToString(), secondOperand.FullName, location)); } return(BoolType.Instance); }
public override object Exec(TypeVariable firstOperand, object arg) { if (firstOperand.Substitution != null) { DynVarOptions.Instance.AssignDynamism(firstOperand.Substitution, firstOperand.IsDynamic); return(firstOperand.Substitution.AcceptOperation(this, arg)); } if (methodAnalyzed != null) { // * A constraint is added to the method analyzed RelationalConstraint constraint = new RelationalConstraint(firstOperand, secondOperand, relationalOperator, location); methodAnalyzed.AddConstraint(constraint); return(constraint.ReturnType); } return(ReportError(firstOperand)); }