// Try to find the appropriate attribute public override object Exec(InterfaceType d, object arg) { UnconstrainedDotOperation uo = new UnconstrainedDotOperation(this.memberName, this.previousDot); TypeExpression member = (TypeExpression)d.AcceptOperation(uo, arg); if (member == null) { // * Otherwise, error ErrorManager.Instance.NotifyError(new UnknownMemberError(this.memberName, this.location)); } return(member); }
public override object Exec(InterfaceType firstOperand, object arg) { int aux, less = -1; // * Equivalent types if ((bool)firstOperand.AcceptOperation(new EquivalentOperation(this.secondOperand), arg)) { less = 0; } // * WriteType variable TypeVariable typeVariable = this.secondOperand as TypeVariable; if (typeVariable != null) { if (typeVariable.Substitution != null) { // * If the variable is bounded, the promotion is the one of its substitution return(firstOperand.AcceptOperation(new PromotionLevelOperation(typeVariable.EquivalenceClass.Substitution), arg)); } // * A free variable is complete promotion return(0); } // * Field type and bounded type variable FieldType fieldType = TypeExpression.As <FieldType>(this.secondOperand); if (fieldType != null) { return(firstOperand.AcceptOperation(new PromotionLevelOperation(fieldType.FieldTypeExpression), arg)); } // * Interface List if (firstOperand.InterfaceList.Count != 0) { for (int i = 0; i < firstOperand.InterfaceList.Count; i++) { if ((bool)firstOperand.InterfaceList[i].AcceptOperation(new EquivalentOperation(this.secondOperand), arg)) { if ((less > 1) || (less == -1)) { less = 1; } } else { aux = (int)firstOperand.InterfaceList[i].AcceptOperation(this, arg); if (aux != -1) { if (less > aux + 1 || less == -1) { less = aux + 1; } } } } } if (less != -1) { return(less); } // * Union type UnionType unionType = TypeExpression.As <UnionType>(this.secondOperand); if (unionType != null) { return(unionType.SuperType(firstOperand)); } // * No promotion return(-1); }