public override object Exec(UnionType a, object arg) { // * If all the types in typeset generate a constraint, we simply generate one constraint using the whole union type if (a.IsFreshVariable() && this.methodAnalyzed != null) { // * A constraint is added to the method analyzed SquareBracketConstraint constraint = new SquareBracketConstraint(a, this.index, this.location); this.methodAnalyzed.AddConstraint(constraint); return(constraint.ReturnType); } TypeExpression returnType = null; foreach (TypeExpression type in a.TypeSet) { TypeExpression ret = (TypeExpression)type.AcceptOperation(new SquareBracketOperation(a, this.methodAnalyzed, !a.IsDynamic && this.showErrorMessage, this.location), arg); if (ret == null && !a.IsDynamic) { return(null); } if (ret != null) { returnType = UnionType.collect(returnType, ret); } } return(returnType); }
public override object Exec(TypeVariable a, object arg) // this is a likely array { TypeExpression subtitutions = a.Substitution; if (subtitutions != null) { DynVarOptions.Instance.AssignDynamism(subtitutions, a.IsDynamic); return(subtitutions.AcceptOperation(this, arg)); } if (this.methodAnalyzed != null) { // * A bracket constraint is added to the method analyzed SquareBracketConstraint bracketConstraint = new SquareBracketConstraint(a, this.index, this.location); this.methodAnalyzed.AddConstraint(bracketConstraint); // * Also a promotion constriaint of the index to IntType //index.Promotion(IntType.Instance, ArrayOperator.Indexer, methodAnalyzed, fileName, line, column); return(bracketConstraint.ReturnType); } // We are at this point the operation is invalid, report the error.? return(ReportError(a)); }