[svn] r7758: nemerle/trunk/ncc/generation/ILEmitter.n nemerle/trunk/ncc/typing/Typer.n vs-plugin/trunk/Nem...

IT svnadmin at nemerle.org
Sun Aug 12 06:52:41 CEST 2007


Log:
Working on debugging.



Author: IT
Date: Sun Aug 12 06:52:33 2007
New Revision: 7758

Modified:
   nemerle/trunk/ncc/generation/ILEmitter.n
   nemerle/trunk/ncc/typing/Typer.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n

Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n	Sun Aug 12 06:52:33 2007
@@ -657,7 +657,7 @@
               emit_debug_info (TExpr.DebugInfo (loc, null, null, null));
           }
 
-          def emit_branch (expr : TExpr, else_label : Label, _debug_loc: Location) {
+          def emit_branch (expr : TExpr, else_label : Label, debug_loc: Location) {
             MaybeMark (expr.Location);
             match (expr) {
               | Call (OpCode ("=="), [nested_cond,
@@ -669,12 +669,12 @@
 
                 /* NOTE: the opcodes are swapped so that the 'then' expression
                          can be emitted before the 'else' expression */
+                if (_debug_doc == null || debug_loc.IsGeneratedOrEmpty)
+                {
                 def opcode =
                   match (opcode) {
-                    | "==.ref"
-                    | "==" => OpCodes.Bne_Un
-                    | "!=.ref"
-                    | "!=" => OpCodes.Beq
+                      | "==.ref" | "=="   => OpCodes.Bne_Un
+                      | "!=.ref" | "!="   => OpCodes.Beq
                     | "<.s" | "<.f" => OpCodes.Bge
                     | "<.u" => OpCodes.Bge_Un
                     | ">.s" | ">.f" => OpCodes.Ble
@@ -688,6 +688,33 @@
                                      "' in optimized TExpr.If pattern")
                   };
                 _ilg.Emit (opcode, else_label);
+                }
+                else
+                {
+                  def opcode =
+                    match (opcode) {
+                      | "==.ref" | "=="   => OpCodes.Beq
+                      | "!=.ref" | "!="   => OpCodes.Bne_Un
+                      | "<.s"    | "<.f"  => OpCodes.Blt
+                      | "<.u"             => OpCodes.Blt_Un
+                      | ">.s"    | ">.f"  => OpCodes.Bgt
+                      | ">.u"             => OpCodes.Bgt_Un
+                      | "<=.s"   | "<=.f" => OpCodes.Ble
+                      | "<=.u"            => OpCodes.Ble_Un
+                      | ">=.s"   | ">=.f" => OpCodes.Bge
+                      | ">=.u"            => OpCodes.Bge_Un
+                      | "bool.!"          => OpCodes.Brfalse
+                      | _ => Util.ice ("invalid opcode '" + opcode +
+                                       "' in optimized TExpr.If pattern")
+                    };
+
+                  def debug_label = _ilg.DefineLabel ();
+
+                  _ilg.Emit (opcode, debug_label);
+                  emit_debug (debug_loc);
+                  _ilg.Emit (OpCodes.Br, else_label);
+                  _ilg.MarkLabel (debug_label);
+                }
 
               | HasType (val, ty) =>
                 limited_debug_nesting++;
@@ -2321,11 +2348,11 @@
         _document = document;
       }
 
-      public BeginCatchBlock (tp : Type) : void  { _ilg.BeginCatchBlock(tp)      }
+      public BeginCatchBlock (tp : Type) : void  { _throw = false; _ilg.BeginCatchBlock(tp)      }
       public BeginExceptFilterBlock ()   : void  { _ilg.BeginExceptFilterBlock() }
       public BeginExceptionBlock    ()   : Label { _ilg.BeginExceptionBlock()    }
       public BeginFaultBlock        ()   : void  { _ilg.BeginFaultBlock()        }
-      public BeginFinallyBlock      ()   : void  { _ilg.BeginFinallyBlock()      }
+      public BeginFinallyBlock      ()   : void  { _throw = false; _ilg.BeginFinallyBlock()      }
       public EndExceptionBlock      ()   : void  { _ilg.EndExceptionBlock()      }
 
       public ThrowException (excType : Type) : void { _ilg.ThrowException(excType) }

Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n	(original)
+++ nemerle/trunk/ncc/typing/Typer.n	Sun Aug 12 06:52:33 2007
@@ -1945,7 +1945,7 @@
 
             loc = nm.Location;
 
-          | DefFunctions (funs) =>
+          | PT.PExpr.DefFunctions (funs) =>
 
             loc = Location.Default;
             funs.Iter (f => {
@@ -1964,6 +1964,7 @@
             loc   = pexpr.Location;
             pexpr = PT.PExpr.Sequence (loc, []);
 
+          | PT.PExpr.Try => loc = Location.Default;
           | _ =>
 
             truncateLoc();

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	Sun Aug 12 06:52:33 2007
@@ -59,10 +59,14 @@
 
     GetTypedObject(obj : object) : object
     {
-      | pe is PExpr        => pe.TypedObject;
-      | fh is P.Fun_header => fh.TypedObject;
-      | fp is P.Fun_parm   => fp.TypedObject;
-      | sp is Splicable    => sp.TypedObject : object;
+      | pe is PExpr        => GetTypedObject(pe.TypedObject);
+      | fh is P.Fun_header => GetTypedObject(fh.TypedObject);
+      | fp is P.Fun_parm   => GetTypedObject(fp.TypedObject);
+      | sp is Splicable    => GetTypedObject(sp.TypedObject);
+      | TExpr.Delayed(susp) when !susp.IsResolved =>
+          susp.Resolve();
+          if (susp.IsResolved) susp.ResolutionResult else null
+      | _  is TExpr        => obj;
       | _                  => null;
     }
 
@@ -95,7 +99,6 @@
             | PExpr.Wildcard => info.Stop();
             | PExpr.MacroCall(name, _, _) when IsIn(name.Location) =>
 
-              _debug(info.Node);
               _location = name.Location;
               info.Stop();
 
@@ -177,7 +180,7 @@
       {
         Init(line, col);
 
-        ExprWalker().Walk(pRoot, PFinder);
+        ExprWalker(this).Walk(pRoot, PFinder);
 
         if (_texprObject != null)
         {
@@ -346,12 +349,6 @@
 
       ignore(level);
     }
-
-    _debug(o : object) : void
-    {
-      when (o != null)
-        _ = o.ToString();
-    }
   }
 }
   
\ No newline at end of file



More information about the svn mailing list