[svn] r7276: nemerle/trunk/ncc/parsing: MainParser.n ParseTree.n

VladD2 svnadmin at nemerle.org
Tue Jan 16 15:36:05 CET 2007


Log:
1. Add DefinedIn propery to TopDeclaration and ClassMember variants.
2. Fix location of nested types.

Author: VladD2
Date: Tue Jan 16 15:36:04 2007
New Revision: 7276

Modified:
   nemerle/trunk/ncc/parsing/MainParser.n
   nemerle/trunk/ncc/parsing/ParseTree.n

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Tue Jan 16 15:36:04 2007
@@ -670,6 +670,14 @@
 
                     | _ => Util.ice ()
                   };
+
+                // Add references to TopDeclaration where members is defined.
+                foreach (member in members) {
+                  | TypeDeclaration(nestedType) => member._definedIn     = td;
+                                                   nestedType._definedIn = td;
+                  | _                           => member._definedIn     = td;
+                }
+
                 td.name = name;
                 td.loc = startLocation + end_loc;
                 td
@@ -791,7 +799,7 @@
 
               | _ =>
                 take_attributes_out (ref customs, System.AttributeTargets.Class, true, mods);
-                def td = ParseTypeDeclaration (mods, tok.Location);
+                def td = ParseTypeDeclaration (mods, start_tok.Location);
                 ClassMember.TypeDeclaration (loc = td.loc, 
                                              name = td.name, 
                                              modifiers = td.modifiers, 

Modified: nemerle/trunk/ncc/parsing/ParseTree.n
==============================================================================
--- nemerle/trunk/ncc/parsing/ParseTree.n	(original)
+++ nemerle/trunk/ncc/parsing/ParseTree.n	Tue Jan 16 15:36:04 2007
@@ -32,7 +32,7 @@
 
 namespace Nemerle.Compiler.Parsetree
 {
-  [Record]
+  [Record (Exclude = [_definedIn])]
   public variant TopDeclaration : DeclarationBase
   {
     | Class {
@@ -63,6 +63,10 @@
     }
 
     public mutable typarms : Typarms;
+    /// If this TopDeclaration nested in other TopDeclaration
+    /// this property contain referens to it.  This property set to null 
+    /// if it is top level declaration.
+    [Accessor] internal mutable _definedIn : TopDeclaration;
 
     public this (tp : Typarms) {
       this ();
@@ -72,7 +76,7 @@
     public this () { base (Splicable.Name (Name ("")), Modifiers.Empty) }
   }
 
-  [Record (Exclude = [Env, Tokens, BodyLocation])]
+  [Record (Exclude = [Env, Tokens, BodyLocation, _definedIn])]
   public variant ClassMember : DeclarationBase
   {
     | TypeDeclaration { td : TopDeclaration; }
@@ -100,9 +104,12 @@
     public mutable Env : GlobalEnv;
     internal mutable Tokens : Token.BracesGroup;
     internal mutable BodyLocation : Location;
+    /// This property contain referens to TopDeclaration where defined this member.
+    [Accessor] internal mutable _definedIn : TopDeclaration;
     
     /** accessible only for ClassMember.Function, when its FunBody is not typed or compiled */
-    public Body : PExpr {
+    public Body : PExpr
+    {
       get {
         match (this) {
           | ClassMember.Function (body = bd) =>



More information about the svn mailing list