public override object Exec(TypeExpression operand1, object arg) { if (this.operand2 == operand1) { return(true); } TypeVariable typeVariable = this.operand2 as TypeVariable; if (typeVariable != null) { return(typeVariable.AcceptOperation(new EquivalentOperation(operand1), arg)); } FieldType fieldType = this.operand2 as FieldType; if (fieldType != null) { return(fieldType.AcceptOperation(this, arg)); } UnionType unionType = this.operand2 as UnionType; if (unionType != null) { return(this.operand2.FullName.Contains(operand1.FullName)); } return(operand1.FullName.Equals(this.operand2.FullName)); }
/// <summary> /// Checks the constraints of a attribute assigment in 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="activeSortOfUnification">The active sort of unification used (Equivalent is the default /// one and Incremental is used in the SSA bodies of the while, for and do statements)</param> /// <param name="location">Location of the method call</param> /// <returns>The return type expression</returns> public override TypeExpression Check(MethodType methodAnalyzed, TypeExpression actualImplicitObject, bool showInvocationMessage, SortOfUnification activeSortOfUnification, Location location) { if (this.alpha.Substitution == null) { this.alpha.AcceptOperation(new AssignmentOperation(this.beta, AssignmentOperator.Assign, methodAnalyzed, this.sortOfUnification, actualImplicitObject, location), null); return(this.alpha); } FieldType fieldType = this.alpha.Substitution as FieldType; if (fieldType == null) { ErrorManager.Instance.NotifyError(new UnknownMemberError(this.memberName, location)); return(null); } SortOfUnification unification = activeSortOfUnification == SortOfUnification.Incremental ? SortOfUnification.Incremental: this.sortOfUnification; fieldType.AcceptOperation(new AssignmentOperation(this.beta, AssignmentOperator.Assign, methodAnalyzed, unification, actualImplicitObject, location), null); return(fieldType); }