logo       

External method that use System.Query's ExtensionAttribute: msg#00012

lang.nemerle.devel

Subject: External method that use System.Query's ExtensionAttribute

This is a multi-part message in MIME format.In the forums, I posted about the Nemerle compiler being able to use System.Query's ExtensionAttribute apart from the one from Nemerle libs. The patch that was made was OK (although it sometime produced subtle errors in the compiler).
But this morning I've seen the code from extension methods have been refactored, and I've made some work using S.Q's attribute (mostly taken from your previous patch). I attach that patch, please tell me if it is OK to commit or not.

Trupill

P.S.: One more question, I've been doing some tests, and it seems that if I define a extension method for IEnumerable['a] it does not work for IEnumerable[string] :-(
Index: ncc/external/LibrariesLoader.n
===================================================================
--- ncc/external/LibrariesLoader.n (revisión: 6266)
+++ ncc/external/LibrariesLoader.n (copia de trabajo)
@@ -361,6 +361,12 @@
when (t != null)
SystemType.ExtensionAttribute = t;
}
+
+ when (SystemType.SQ_ExtensionAttribute == null) {
+ def t = assembly.GetType
("System.Runtime.CompilerServices.ExtensionAttribute");
+ when (t != null)
+ SystemType.SQ_ExtensionAttribute = t;
+ }

mutable i = 0;
for (; i < types.Length; ++i) {
@@ -1341,6 +1347,15 @@
LibraryReferenceManager.AddExtensionMethod (m);
}
}
+
+ when (SystemType.SQ_ExtensionAttribute != null) {
+ def t = SystemType.SQ_ExtensionAttribute;
+ when (system_type.IsDefined (t, false)) {
+ foreach (m is IMethod in GetMembers ())
+ when (m.IsStatic && m.GetHandle ().IsDefined (t, false))
+ LibraryReferenceManager.AddExtensionMethod (m);
+ }
+ }
}
}

Index: ncc/external/InternalTypes.n
===================================================================
--- ncc/external/InternalTypes.n (revisión: 6266)
+++ ncc/external/InternalTypes.n (copia de trabajo)
@@ -72,6 +72,7 @@

// set in LibrariesLoader upon first possiblity
public mutable ExtensionAttribute : System.Type;
+ public mutable SQ_ExtensionAttribute : System.Type;

public mutable Decimal_ctors : Hashtable [string, SR.ConstructorInfo];
public mutable Type_GetTypeFromHandle : SR.MethodInfo;


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise