[svn] r7524: nemerle/trunk/ncc: generation/ILEmitter.n typing/MType.n

IT svnadmin at nemerle.org
Thu Mar 8 06:07:17 CET 2007


Log:
Working on debug locations.

Author: IT
Date: Thu Mar  8 06:07:15 2007
New Revision: 7524

Modified:
   nemerle/trunk/ncc/generation/ILEmitter.n
   nemerle/trunk/ncc/typing/MType.n

Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n	Thu Mar  8 06:07:15 2007
@@ -182,11 +182,13 @@
     }
 
     mutable debug_tmp_disabled : bool;
+    mutable prev_location      : Location;
 
     /** Marks the point in source file for currently emmited opcode */
     Mark (loc : Location) : void
     {
-      when (IsDebugEnabled && loc.Line != 0 && !debug_tmp_disabled) {
+      when (IsDebugEnabled && loc.Line != 0 && !debug_tmp_disabled && !prev_location.Contains(loc)) {
+        prev_location = loc;
         Util.cassert (loc.Line <= loc.EndLine, "spoiled location " + loc.File + " " + loc.ToString ());
         _ilg.MarkSequencePoint (_debug_doc, loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
       }
@@ -519,6 +521,31 @@
       _ = loc.Location;
     }
 
+    MarkCall(call : TExpr.Call, loc : Location) : void
+    {
+      when (IsDebugEnabled)
+      {
+        def parm = call.parms.Find(p =>
+          if (p == null || p.required_type == null) false
+          else p.expr.Location.Line != p.expr.Location.EndLine || p.required_type.Fix().IsFunction);
+
+        match (parm)
+        {
+        | None    => Mark (loc);
+        | Some(p) =>
+
+          when (loc.Line < p.expr.Location.Line ||
+                loc.Line == p.expr.Location.Line && loc.Column < p.expr.Location.Column)
+            Mark (Location(loc.FileIndex, loc.Line, loc.Column, p.expr.Location.Line, p.expr.Location.Column));
+        }
+      }
+    }
+
+    MarkCall(call : TExpr.Call) : void
+    {
+      MarkCall(call, call.Location);
+    }
+
     /**
      * Emits an expression.
      */
@@ -545,7 +572,13 @@
         
         /* emits a local value definition */
         | DefValIn (decl, let_val, let_in) =>
-          Mark (decl.Location);
+
+          match (let_val)
+          {
+          | Call as call => MarkCall (call, decl.Location.Combine(call.Location));
+          | _            => Mark (decl.Location);
+          }
+
           def newscope = 
             match (let_val) {
               | DefaultValue => 
@@ -1079,8 +1112,8 @@
         /* -- CALLS -------------------------------------------------------- */
 
         /* call the base constructor */
-        | Call (Base (base_ctor), ctor_params, _) =>
-          Mark (expr.loc);
+        | Call (Base (base_ctor), ctor_params, _) as call=>
+          MarkCall (call);
           _ilg.Emit (OpCodes.Ldarg_0);
           emit_parms (ctor_params);
 
@@ -1095,8 +1128,8 @@
             _ilg.Emit (OpCodes.Ret);
 
         /* create a new object */
-        | Call (StaticRef (_t, meth is IMethod, _), ctor_params, _) when is_ctor (meth) =>
-          Mark (expr.loc);
+        | Call (StaticRef (_t, meth is IMethod, _), ctor_params, _) as call when is_ctor (meth) =>
+          MarkCall (call);
           emit_parms (ctor_params);
 
           def ctr_inf = GetConstructorInfo (_t.SystemType, meth);          
@@ -1106,9 +1139,9 @@
 
 
         /* emit a call to an instance method, basing on the 'this' pointer for value types */
-        | Call (MethodRef (This as th, method, tparms, _), method_params, _)
+        | Call (MethodRef (This as th, method, tparms, _), method_params, _) as call
                                                       when _this_is_value_type =>
-          Mark (expr.loc);                                                      
+          MarkCall (call);                                                      
           _ilg.Emit (OpCodes.Ldarg_0);
 
           def method_inf = GetMethodInfo (th.Type, method, tparms);
@@ -1124,8 +1157,8 @@
 
 
         /* emit a call to an instance method */
-        | Call (MethodRef (base_object, method, tparms, notvirt), method_params, _) =>
-          Mark (expr.loc);        
+        | Call (MethodRef (base_object, method, tparms, notvirt), method_params, _) as call =>
+          MarkCall (call);
           def is_value_type = emit_and_convert_to_address (base_object);
 
           def method_inf = GetMethodInfo (base_object.Type, method, tparms);
@@ -1147,8 +1180,8 @@
 
 
         /* emit a call to a static method */
-        | Call (StaticRef (_t, mi is IMethod, tparms), method_parms, _) =>
-          Mark (expr.loc);                  
+        | Call (StaticRef (_t, mi is IMethod, tparms), method_parms, _) as call =>
+          MarkCall (call);
           def method_info = GetMethodInfo (_t, mi, tparms);          
         
           Util.cassert (method_info.IsStatic, 
@@ -1159,8 +1192,8 @@
 
 
         /* emit an operator */
-        | Call (OpCode (opcode), parms, _) =>
-          MaybeMark (expr.loc);
+        | Call (OpCode (opcode), parms, _) as call =>
+          MarkCall (call);
           // FIXME: seperate out
           emit_parms (parms);
           match (opcode) {

Modified: nemerle/trunk/ncc/typing/MType.n
==============================================================================
--- nemerle/trunk/ncc/typing/MType.n	(original)
+++ nemerle/trunk/ncc/typing/MType.n	Thu Mar  8 06:07:15 2007
@@ -580,6 +580,17 @@
     }
 
 
+    public IsFunction : bool
+    {
+      get {
+        match (this) {
+          | Fun => true
+          | _   => false
+        }
+      }
+    }
+
+
     public TypeInfo : TypeInfo
     {
       get {



More information about the svn mailing list