[svn] r5849: nemerle/trunk: macros/core.n
ncc/hierarchy/MacroClassGen.n ncc/hierarchy/TypeBuilder.n ncc/hi...
nazgul
svnadmin at nemerle.org
Tue Oct 25 21:50:37 CEST 2005
Log:
Some preparations for priority queue based macro expansion
Author: nazgul
Date: Tue Oct 25 21:50:28 2005
New Revision: 5849
Modified:
nemerle/trunk/macros/core.n
nemerle/trunk/ncc/hierarchy/MacroClassGen.n
nemerle/trunk/ncc/hierarchy/TypeBuilder.n
nemerle/trunk/ncc/hierarchy/TypesManager.n
nemerle/trunk/ncc/parsing/AST.n
nemerle/trunk/ncc/typing/Macros.n
Modified: nemerle/trunk/macros/core.n
==============================================================================
--- nemerle/trunk/macros/core.n (original)
+++ nemerle/trunk/macros/core.n Tue Oct 25 21:50:28 2005
@@ -971,8 +971,7 @@
def meths = t.GetMethods (BindingFlags.Public %| BindingFlags.NonPublic %|
BindingFlags.Instance %| BindingFlags.Static %| BindingFlags.DeclaredOnly);
foreach (x : IMethod in meths) {
- x.GetModifiers ().macro_attrs = (":method:postadd", <[ $("Nemerle" : usesite).Diagnostics.Trace ($tracecall) ]>)
- :: x.GetModifiers ().macro_attrs;
+ x.GetModifiers ().AddCustomAttribute (<[ $("Nemerle" : usesite).Diagnostics.Trace ($tracecall) ]>);
}
}
Modified: nemerle/trunk/ncc/hierarchy/MacroClassGen.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/MacroClassGen.n (original)
+++ nemerle/trunk/ncc/hierarchy/MacroClassGen.n Tue Oct 25 21:50:28 2005
@@ -347,7 +347,7 @@
(pats, exps, List.Rev (accmp))
| [ Fun_parm where (name = Splicable.Name (va), ty = t,
- modifiers = Modifiers where (_, [<[ System.ParamArrayAttribute ]>], _) ) ] =>
+ modifiers = Modifiers where (custom_attrs = [<[ System.ParamArrayAttribute ]>]) ) ] =>
// variable amount of parameters is handled here
def (initpat, initex) =
match (acc) {
@@ -395,7 +395,7 @@
| (Fun_parm where ( name = Splicable.Name (va), ty = t,
modifiers = Modifiers where
- (_, [<[ System.ComponentModel.DefaultValueAttribute ($e) ]>], _) )) :: xs =>
+ (custom_attrs = [<[ System.ComponentModel.DefaultValueAttribute ($e) ]>]) )) :: xs =>
// parameter with default value
match (normal_parm (t, va)) {
| (p, str :: strs, macroparm) =>
Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n (original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n Tue Oct 25 21:50:28 2005
@@ -123,7 +123,7 @@
instance_ctor_occured = true;
enclosing_type.variant_options = this :: enclosing_type.variant_options;
attributes |= NemerleAttributes.Sealed;
- modifiers.macro_attrs = (":type:postadd", <[ Record ]>) :: modifiers.macro_attrs;
+ modifiers.custom_attrs = <[ Record ]> :: modifiers.custom_attrs;
if (enclosing_type.IsPublic)
attributes |= NemerleAttributes.Public
else
@@ -1315,7 +1315,7 @@
}
modifiers.custom_attrs += additional.GetCustomAttributes ();
- modifiers.macro_attrs += additional.modifiers.macro_attrs;
+ //modifiers.macro_attrs += additional.modifiers.macro_attrs;
}
@@ -2241,10 +2241,11 @@
match (MacroRegistry.lookup_macro (this.GlobalEnv, expr, suff)) {
| None => true
| Some =>
- macro_attrs = (suff, expr) :: macro_attrs;
+ macro_attrs ::= (suff, expr);
false
}
});
+ mods.macro_attrs = macro_attrs;
foreach ((_, expr) in macro_attrs)
{
match (MacroRegistry.lookup_macro (this.GlobalEnv, expr, suff)) {
@@ -2265,7 +2266,6 @@
assert (res == null);
}
};
- mods.macro_attrs = macro_attrs;
};
def process_member (mem, stage_suff) {
Modified: nemerle/trunk/ncc/hierarchy/TypesManager.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypesManager.n (original)
+++ nemerle/trunk/ncc/hierarchy/TypesManager.n Tue Oct 25 21:50:28 2005
@@ -36,6 +36,23 @@
protected mutable infos : list [TypeBuilder] = [];
internal mutable run_phase : int;
+ protected attribute_macros_queue : Nemerle.Collections.Heap [AttributeMacroExpansion] = Nemerle.Collections.Heap (100);
+
+ protected class AttributeMacroExpansion : System.IComparable [AttributeMacroExpansion]
+ {
+ public Phase : MacroPhase;
+ public Target : MacroTargets;
+
+ /// we need the earlier expanded macros to get the highest values, as heap is returning max values first
+ public CompareTo (other : AttributeMacroExpansion) : int
+ {
+ // larger phase values should be expanded later
+ if (Phase != other.Phase) (other.Phase :> int) - (Phase :> int)
+ else (other.Target :> int) - (Target :> int)
+ }
+ }
+
+
public CreateTypeBuilder (par : TypeBuilder, td : Parsetree.TopDeclaration,
ns_node : NamespaceTree.Node) : TypeBuilder
{
Modified: nemerle/trunk/ncc/parsing/AST.n
==============================================================================
--- nemerle/trunk/ncc/parsing/AST.n (original)
+++ nemerle/trunk/ncc/parsing/AST.n Tue Oct 25 21:50:28 2005
@@ -252,7 +252,7 @@
{
public mutable mods : NemerleAttributes;
public mutable custom_attrs : list [Parsetree.PExpr];
- public mutable macro_attrs : list [string * Parsetree.PExpr];
+ internal mutable macro_attrs : list [string * Parsetree.PExpr];
public static Empty : Modifiers;
Modified: nemerle/trunk/ncc/typing/Macros.n
==============================================================================
--- nemerle/trunk/ncc/typing/Macros.n (original)
+++ nemerle/trunk/ncc/typing/Macros.n Tue Oct 25 21:50:28 2005
@@ -279,7 +279,7 @@
def qparms =
match (parms) {
| [Fun_parm where (name = Splicable.Name, ty = PExpr.Void,
- modifiers = Modifiers where (_, [PExpr.Ellipsis (e)], _))] => quoted_expr (e)
+ modifiers = Modifiers where (custom_attrs = [PExpr.Ellipsis (e)]))] => quoted_expr (e)
| _ => Lift (parms, quoted_fparam)
};
@@ -298,7 +298,7 @@
quoted_attributes (attrs : Modifiers) : PExpr
{
match (attrs) {
- | Modifiers where (_, [PExpr.Ellipsis (e)], _) => quoted_expr (e)
+ | Modifiers where (custom_attrs = [PExpr.Ellipsis (e)]) => quoted_expr (e)
| _ =>
<[ Modifiers (($((attrs.mods :> int) : int) :> NemerleAttributes),
$(Lift (attrs.custom_attrs, quoted_expr))) ]>
More information about the svn
mailing list