[svn] r6923: nemerle/trunk/ncc: hierarchy/ClassMembers.n parsing/MainParser.n parsing/ParseTree.n

VladD2 svnadmin at nemerle.org
Fri Nov 17 05:15:40 CET 2006


Log:
Fix locations of property.

Author: VladD2
Date: Fri Nov 17 05:15:37 2006
New Revision: 6923

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

Modified: nemerle/trunk/ncc/hierarchy/ClassMembers.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/ClassMembers.n	(original)
+++ nemerle/trunk/ncc/hierarchy/ClassMembers.n	Fri Nov 17 05:15:37 2006
@@ -540,6 +540,8 @@
   setter : MethodBuilder;
   internal parms : list [MType];
   mutable parent_property : IProperty = null;
+  [Accessor (flags = Override)]
+  protected mutable _bodyLocation : Location;
   
   internal mutable property_builder : SRE.PropertyBuilder;
 
@@ -552,6 +554,8 @@
   {
     base (par, propertyAst);
 
+    //TODO: Add BodyLocation support to fields and event
+    _bodyLocation = propertyAst.BodyLocation;
     is_mutable = Option.IsSome (propertyAst.set);
     ty = par.MonoBindType (propertyAst.prop_ty);
 

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Fri Nov 17 05:15:37 2006
@@ -739,7 +739,7 @@
                 def typarms = parse_where_constraints (tyvars);
 
                 if (is_property)
-                  parse_property (mods, customs, id, ret_type, parms, typarms)
+                  parse_property (start_tok.Location, mods, customs, id, ret_type, parms, typarms)
                 else {
                   def header = Fun_header (start_tok.Location + ret_type.Location,
                                            name = id,
@@ -891,11 +891,12 @@
       };
     }
     
-    parse_property (mods : Modifiers, mutable customs : list [Token.SquareGroup],
+    parse_property (startLocation : Location, mods : Modifiers, 
+                    mutable customs : list [Token.SquareGroup],
                     id : Splicable, ret_type : PExpr, parms : list [Fun_parm],
                     typarms : Typarms) : ClassMember
     {
-      def loc = id.Location + ret_type.Location;
+      def loc = startLocation + ret_type.Location;
       mutable impl = [];
       when (flag_keyword ("implements"))
         impl = comma_separated_list (fun () { parse_expr (TokenStoppers.All) });
@@ -910,25 +911,26 @@
 
           def plain_name = match (id) { | Splicable.Name (n) => n.Id | _ => "" };
           
-          def prop_ty = Util.locate (loc, 
-            match (parms) {
-              | [parm] => <[ $(parm.ty) -> $ret_type ]>
+          def prop_ty = match (parms) {
+            | [parm]     => Util.locate (parm.Location + ret_type.Location, 
+                              <[ $(parm.ty) -> $ret_type ]>)
               | [] => ret_type
-              | _ =>
-                def input_parms = List.Map (parms, fun (x : Fun_parm) { x.ty });
-                <[ @* (..$input_parms) -> $ret_type ]>
+            | first :: _ => def input_parms = parms.Map (_.ty);
+                            Util.locate (first.Location + ret_type.Location,
+                              <[ @* (..$input_parms) -> $ret_type ]>)
             }
-          );
 
-          foreach (Token.LooseGroup (toks) in group) {
+          foreach (Token.LooseGroup (toks) in group) 
+          {
             push_stream (toks);
+            def next = toks.Next;
+            def loc2 = if (next == null) toks.Location else toks.Location + next.Location;
             mutable mycustoms = get_customs ();
             def mymods = get_modifiers ();
 
             match (get_token ()) {
               | Token.Identifier (i) as nametok =>
-                def loc = nametok.Location;
-                Util.locate (loc, 
+                Util.locate (loc2, 
                   match (i) {
                     | "get" =>
                       unless (getter.IsNone)
@@ -940,7 +942,7 @@
 
                       def (kind, bd) = parse_accessor_body ([], impl);
                       def name = Splicable.Name (mkname ("get_" + plain_name));
-                      def fh = Fun_header (loc, name, ret_type, parms);
+                      def fh = Fun_header (toks.Location + nametok.Location, name, ret_type, parms);
                       def member = ClassMember.Function (fh.name, method_atts, fh, kind, bd);
                       member.Env = env;
                       getter = Some (member);
@@ -961,7 +963,8 @@
 
                       def (kind, bd) = parse_accessor_body (setter_parms, impl);
                       def name = Splicable.Name (mkname ("set_" + plain_name));
-                      def fh = Fun_header (loc, typarms, name, PExpr.Void (), setter_parms);
+                      def fh = Fun_header (toks.Location + nametok.Location, 
+                                           typarms, name, PExpr.Void (), setter_parms);
                       def member = ClassMember.Function (fh.name, method_atts, fh, kind, bd);
                       member.Env = env;
                       setter = Some (member);
@@ -985,7 +988,12 @@
             }
             pop_stream ("property member");
           }
-          ClassMember.Property (loc, id, mods, ret_type, prop_ty, parms, getter, setter);
+
+          def prop = ClassMember.Property (loc + group.Location, id, mods, 
+            ret_type, prop_ty, parms, getter, setter);
+
+          prop.BodyLocation = group.Location;
+          prop
 
         | Token.Operator ("=") =>
           shift ();

Modified: nemerle/trunk/ncc/parsing/ParseTree.n
==============================================================================
--- nemerle/trunk/ncc/parsing/ParseTree.n	(original)
+++ nemerle/trunk/ncc/parsing/ParseTree.n	Fri Nov 17 05:15:37 2006
@@ -72,7 +72,7 @@
     public this () { base (Splicable.Name (Name ("")), Modifiers.Empty) }
   }
 
-  [Record (Exclude = [Env, Tokens])]
+  [Record (Exclude = [Env, Tokens, BodyLocation])]
   public variant ClassMember : DeclarationBase
   {
     | TypeDeclaration { td : TopDeclaration; }
@@ -99,6 +99,7 @@
 
     public mutable Env : GlobalEnv;
     internal mutable Tokens : Token.BracesGroup;
+    internal mutable BodyLocation : Location;
     
     /** accessible only for ClassMember.Function, when its FunBody is not typed or compiled */
     public Body : PExpr {



More information about the svn mailing list