[svn] r7117: nemerle/trunk/ncc: generation/DecisionTreeCompiler.n generation/ILEmitter.n generation/Typer3...

nazgul svnadmin at nemerle.org
Mon Dec 18 20:19:09 CET 2006


Log:
Hacks here and there to mark meaningful places of code with locations for debugger

Author: nazgul
Date: Mon Dec 18 20:19:06 2006
New Revision: 7117

Modified:
   nemerle/trunk/ncc/generation/DecisionTreeCompiler.n
   nemerle/trunk/ncc/generation/ILEmitter.n
   nemerle/trunk/ncc/generation/Typer3.n
   nemerle/trunk/ncc/parsing/MainParser.n

Modified: nemerle/trunk/ncc/generation/DecisionTreeCompiler.n
==============================================================================
--- nemerle/trunk/ncc/generation/DecisionTreeCompiler.n	(original)
+++ nemerle/trunk/ncc/generation/DecisionTreeCompiler.n	Mon Dec 18 20:19:06 2006
@@ -427,7 +427,7 @@
     
     static If (cond : TExpr, e1 : TExpr, e2 : TExpr) : TExpr
     {
-      TExpr.If (Location.Default, e1.Type, cond, e1, e2)
+      TExpr.If (e1.Type, cond, e1, e2)
     }
 
     static Cast (expr : TExpr, ty : TyVar) : TExpr

Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n	Mon Dec 18 20:19:06 2006
@@ -114,7 +114,15 @@
 
       match (_fun_header.body) {
         | FunBody.Typed (body) =>
+          when (IsDebugEnabled) {
+            Mark (body.Location.FromStart ());
+            _ilg.Emit (OpCodes.Nop);   
+          }
           emit (body);
+          
+          when (IsDebugEnabled) {
+            Mark (body.Location.FromEnd());
+          }
           unless (body.Throws)
             _ilg.Emit (OpCodes.Ret);
           // let GC take it
@@ -182,12 +190,16 @@
     /** Marks the point in source file for currently emmited opcode */
     Mark (loc : Location) : void
     {
-      when (_debug_doc != null && loc.Line != 0) {
+      when (IsDebugEnabled && loc.Line != 0) {
         Util.cassert (loc.Line <= loc.EndLine, "spoiled location " + loc.File + " " + loc.ToString ());
         _ilg.MarkSequencePoint (_debug_doc, loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
       }
     }
 
+    IsDebugEnabled : bool {
+      get { _debug_doc != null }   
+    }
+    
 
     /** Emit volatile prefix if needed. */
     private maybe_volatile (expr : TExpr) : void
@@ -512,6 +524,7 @@
         
         /* emits a local value definition */
         | DefValIn (decl, let_val, let_in) =>
+          Mark (decl.Location);
           def newscope = 
             match (let_val) {
               | DefaultValue => 
@@ -524,7 +537,6 @@
 
               | ImplicitValueTypeCtor =>
                 def slot = declare_val_local_slot (decl);
-                Mark (decl.Location);
                 _ilg.Emit (OpCodes.Ldloca, slot);
                 _ilg.Emit (OpCodes.Initobj, let_val.SystemType);
                 true
@@ -538,7 +550,6 @@
                   false
                 } else {
                   def local_slot = declare_val_local_slot (decl);
-                  Mark (decl.Location);
                   unless (let_val.Throws)
                     _ilg.Emit (OpCodes.Stloc, local_slot);
                   true
@@ -552,7 +563,6 @@
 
         /* emits the if/then/else construction */
         | If (cond_expr, then_expr, else_expr) =>
-          Mark (cond_expr.loc);        
           def emit_branch (expr : TExpr, else_label : Label) {
             Mark (expr.loc);
             match (expr) {
@@ -611,6 +621,10 @@
             }
           }
 
+          when (IsDebugEnabled) {
+            Mark (expr.loc);
+            _ilg.Emit (OpCodes.Nop);
+          }
           def label_condition_else = _ilg.DefineLabel ();
           def label_condition_fi = _ilg.DefineLabel ();
           emit_branch (cond_expr, label_condition_else);

Modified: nemerle/trunk/ncc/generation/Typer3.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer3.n	(original)
+++ nemerle/trunk/ncc/generation/Typer3.n	Mon Dec 18 20:19:06 2006
@@ -183,6 +183,7 @@
 
         match (current_local_fun.body) {
           | FunBody.Typed (body) =>
+            Util.locate (body.Location, {
             // FIXME?: Typed3 
             def body = BuildRevSequence (Walk (body) :: initializers);
             def expr = TExpr.Label (body.Type, start_label, body);
@@ -201,6 +202,7 @@
               def t4 = Typer4 (the_method);
               t4.Run ();
             }
+           })
             
           | _ => assert (false)
         }
@@ -1601,6 +1603,7 @@
           }
         });
 
+      expr.loc = m.Location;
       Walk (expr)
     }
     #endregion

Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n	(original)
+++ nemerle/trunk/ncc/parsing/MainParser.n	Mon Dec 18 20:19:06 2006
@@ -218,7 +218,7 @@
           else {
             def seq = parser.parse_expr_sequence (topstream);
             def class_name = Util.Escape (System.IO.Path.GetFileNameWithoutExtension(lex.Location.File));
-            def decl = Util.locate (topstream.Location, <[ decl:
+            def decl = Util.locate (topstream.Location + lex.Location, <[ decl:
               public class $(parser.mkname (class_name) : name) {
                 public static Main () : void {
                   ..$seq



More information about the svn mailing list