+2009-08-14 Marek Safar <marek.safar@gmail.com>
+
+ * decl.cs, expression.cs, namespace.cs, ecore.cs, class.cs,
+ codegen.cs: Add IResolveContext::LookupExtensionMethod.
+
+2009-08-14 Marek Safar <marek.safar@gmail.com>
+
+ * *.cs: Removed TypeContainer and ContainerType from EmitContext.
+
2009-08-13 Marek Safar <marek.safar@gmail.com>
* decl.cs: Look in PartialContainer for parent type parameters.
get { return tc.IsInUnsafeScope; }
}
+ public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
+ {
+ return null;
+ }
+
public FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
{
return tc.Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
public override ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
{
- return NamespaceEntry.LookupExtensionMethod (extensionType, this, name, loc);
+ DeclSpace top_level = Parent;
+ if (top_level != null) {
+ while (top_level.Parent != null)
+ top_level = top_level.Parent;
+
+ ArrayList candidates = NamespaceEntry.NS.LookupExtensionMethod (extensionType, this, name);
+ if (candidates != null)
+ return new ExtensionMethodGroupExpr (candidates, NamespaceEntry, extensionType, loc);
+ }
+
+ return NamespaceEntry.LookupExtensionMethod (extensionType, name, loc);
}
protected override TypeAttributes TypeAttr {
bool IsInObsoleteScope { get; }
bool IsInUnsafeScope { get; }
+ ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc);
FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104);
Type LookupTypeParameter (string name);
#region IResolveContext Members
+ public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
+ {
+ return ResolveContext.LookupExtensionMethod (extensionType, name, loc);
+ }
+
public FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
{
return ResolveContext.LookupNamespaceOrType (name, loc, ignore_cs0104);
get { return false; }
}
+ public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
+ {
+ throw new NotImplementedException ();
+ }
+
public FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
{
return RootContext.ToplevelTypes.LookupNamespaceOrType (name, loc, ignore_cs0104);
return true;
}
+ public virtual ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
+ {
+ return Parent.LookupExtensionMethod (extensionType, name, loc);
+ }
+
public virtual FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
{
return Parent.LookupNamespaceOrType (name, loc, ignore_cs0104);
return null;
}
- public virtual ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
- {
- return null;
- }
-
//
// Public function used to locate types.
//
return null;
// Search continues
- ExtensionMethodGroupExpr e = ns.LookupExtensionMethod (type, null, Name, loc);
+ ExtensionMethodGroupExpr e = ns.LookupExtensionMethod (type, Name, loc);
if (e == null)
return base.OverloadResolve (ec, ref arguments, false, loc);
// not an extension method. We start extension methods lookup from here
//
if (InstanceExpression != null) {
- ExtensionMethodGroupExpr ex_method_lookup = ec.TypeContainer.LookupExtensionMethod (type, Name, loc);
+ ExtensionMethodGroupExpr ex_method_lookup = ec.LookupExtensionMethod (type, Name, loc);
if (ex_method_lookup != null) {
ex_method_lookup.ExtensionExpression = InstanceExpression;
ex_method_lookup.SetTypeArguments (type_arguments);
return null;
}
- mg = ec.TypeContainer.LookupExtensionMethod (me.Type, me.Name, loc);
+ mg = ec.LookupExtensionMethod (me.Type, me.Name, loc);
if (mg == null) {
Report.Error (1955, loc, "The member `{0}' cannot be used as method or delegate",
expr_resolved.GetSignatureForError ());
if (expr_eclass == ExprClass.Value || expr_eclass == ExprClass.Variable ||
expr_eclass == ExprClass.IndexerAccess || expr_eclass == ExprClass.PropertyAccess ||
expr_eclass == ExprClass.EventAccess) {
- ExtensionMethodGroupExpr ex_method_lookup = ec.TypeContainer.LookupExtensionMethod (expr_type, Name, loc);
+ ExtensionMethodGroupExpr ex_method_lookup = ec.LookupExtensionMethod (expr_type, Name, loc);
if (ex_method_lookup != null) {
ex_method_lookup.ExtensionExpression = expr_resolved;
/// Does extension methods look up to find a method which matches name and extensionType.
/// Search starts from this namespace and continues hierarchically up to top level.
///
- public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, ClassOrStruct currentClass, string name, Location loc)
+ public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
{
ArrayList candidates = null;
- if (currentClass != null) {
- candidates = ns.LookupExtensionMethod (extensionType, currentClass, name);
- if (candidates != null)
- return new ExtensionMethodGroupExpr (candidates, this, extensionType, loc);
- }
-
foreach (Namespace n in GetUsingTable ()) {
ArrayList a = n.LookupExtensionMethod (extensionType, null, name);
if (a == null)
//
// Continue in parent scope
//
- return parent.LookupExtensionMethod (extensionType, currentClass, name, loc);
+ return parent.LookupExtensionMethod (extensionType, name, loc);
}
public FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)