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

IT svnadmin at nemerle.org
Wed Jan 24 07:07:02 CET 2007


Log:
Started working on the correct TExpr location. Most of the features related to location finding is not going to work for a few days.

Author: IT
Date: Wed Jan 24 07:06:51 2007
New Revision: 7328

Modified:
   nemerle/trunk/ncc/generation/ILEmitter.n
   nemerle/trunk/ncc/generation/Typer3.n
   nemerle/trunk/ncc/generation/Typer4.n
   nemerle/trunk/ncc/misc/PrettyPrint.n
   nemerle/trunk/ncc/typing/LocalValue.n
   nemerle/trunk/ncc/typing/TypedTree.n
   nemerle/trunk/ncc/typing/Typer.n
   nemerle/trunk/ncc/typing/Typer2.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n

Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n	Wed Jan 24 07:06:51 2007
@@ -572,7 +572,7 @@
             Mark (expr.loc);
             match (expr) {
               | Call (OpCode ("=="), [nested_cond,
-                 Parm where (expr = TExpr.TypeConversion(TExpr.Literal(Literal.Bool(true)), _, _))], _) =>
+                 Parm where (expr = TExpr.TypeConversion(TExpr.Literal(Literal.Bool(true)), _, _, _))], _) =>
                 emit_branch(nested_cond.expr, else_label)
 
               | Call (OpCode (opcode), parms, _) =>
@@ -765,28 +765,28 @@
 
 
         // when expr throws we shouldn't emit anything
-        | TypeConversion (expr, _, _) when expr.Throws =>
+        | TypeConversion (expr, _, _, _) when expr.Throws =>
           emit (expr)
 
         /* do not perform casts between same types */
-        | TypeConversion (expr, cast_to_type, _) 
+        | TypeConversion (expr, cast_to_type, _, _) 
           when no_cast_needed (expr.SystemType, cast_to_type.SystemType) =>
           emit (expr)
 
         // special case for  'a : 'b conversion
-        | TypeConversion (expr, cast_to_type, ConversionKind.Boxing) 
+        | TypeConversion (expr, cast_to_type, ConversionKind.Boxing, _) 
           when cast_to_type.SystemType.IsGenericParameter =>
           emit (expr);
           _ilg.Emit (OpCodes.Box, expr.SystemType);
           _ilg.Emit (OpCodes.Unbox_Any, cast_to_type.SystemType);
 
-        | TypeConversion (expr, cast_to_type, _) when cast_to_type.SystemType.IsGenericParameter =>
+        | TypeConversion (expr, cast_to_type, _, _) when cast_to_type.SystemType.IsGenericParameter =>
           emit (expr);
           when (expr.MType.IsValueType || expr.MType is MType.TyVarRef)
             _ilg.Emit (OpCodes.Box, expr.SystemType);
           _ilg.Emit (OpCodes.Unbox_Any, cast_to_type.SystemType);
           
-        | TypeConversion (ignored, ty, _) when is_void (ty) =>
+        | TypeConversion (ignored, ty, _, _) when is_void (ty) =>
           Mark (expr.loc);
           // a little trickery, so emit can be tail called sometimes
           if (is_void (ignored.Type))
@@ -797,7 +797,7 @@
           }
         
         /* to nonvalue type */
-        | TypeConversion (expr, cast_to_type, kind) when !cast_to_type.Fix ().IsValueType =>
+        | TypeConversion (expr, cast_to_type, kind, _) when !cast_to_type.Fix ().IsValueType =>
           emit (expr);
           if (is_void (expr.Type))
             /* special case casts from void */
@@ -831,7 +831,7 @@
           }
 
         /* unbox value types or perform value type conversion */
-        | TypeConversion (val, cast_to_type, kind) =>
+        | TypeConversion (val, cast_to_type, kind, _) =>
           MaybeMark (expr.loc);
           def is_checked = ! (kind is IL (false));
           emit (val);

Modified: nemerle/trunk/ncc/generation/Typer3.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer3.n	(original)
+++ nemerle/trunk/ncc/generation/Typer3.n	Wed Jan 24 07:06:51 2007
@@ -1746,8 +1746,8 @@
           TExpr.StaticRef (SubstType (from) :> MType.Class, mem, SubstTypes (tp))
         | MethodRef (obj, meth, tp, nv) =>
           TExpr.MethodRef (SubstExpr (obj), meth, SubstTypes (tp), nv)
-        | TypeConversion (e, t, k) =>
-          TExpr.TypeConversion (SubstExpr (e), SubstType (t), k)
+        | TypeConversion (e, t, k, tl) =>
+          TExpr.TypeConversion (SubstExpr (e), SubstType (t), k, tl)
         | TypeOf (t) =>
           TExpr.TypeOf (SubstType (t))
         | HasType (e, t) =>

Modified: nemerle/trunk/ncc/generation/Typer4.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer4.n	(original)
+++ nemerle/trunk/ncc/generation/Typer4.n	Wed Jan 24 07:06:51 2007
@@ -292,7 +292,7 @@
                 true
               } else false
 
-          | TypeConversion (e, t, _) =>
+          | TypeConversion (e, t, _, _) =>
             #if CHECK_STV
               CheckSTV (t);
             #endif

Modified: nemerle/trunk/ncc/misc/PrettyPrint.n
==============================================================================
--- nemerle/trunk/ncc/misc/PrettyPrint.n	(original)
+++ nemerle/trunk/ncc/misc/PrettyPrint.n	Wed Jan 24 07:06:51 2007
@@ -1184,7 +1184,7 @@
 
         // type related nodes
         // FIXME: checked/unchecked
-        | TT.TExpr.TypeConversion (expr /* TExpr */, target_type /* TType */, kind) =>
+        | TT.TExpr.TypeConversion (expr /* TExpr */, target_type /* TType */, kind, _) =>
           append ("(");
           recurse (expr);
           match (kind) {

Modified: nemerle/trunk/ncc/typing/LocalValue.n
==============================================================================
--- nemerle/trunk/ncc/typing/LocalValue.n	(original)
+++ nemerle/trunk/ncc/typing/LocalValue.n	Wed Jan 24 07:06:51 2007
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004 The University of Wroclaw.
+ * Copyright (c) 2003, 2007 The University of Wroclaw.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,44 +34,31 @@
 {
   public class LocalValue : Located, Nemerle.IComparable [LocalValue]
   {
-    [Accessor]
-    name : string;
-    [Accessor]
-    is_mutable : bool;
     mutable ty : TyVar;
-    kind : Kind;
-    [Accessor]
-    defined_in : Fun_header;
-
-    id : int;
-    [Accessor]
-    mutable used_in : Set [Fun_header];
-
-    [Accessor (flags = WantSetter)]
-    mutable in_closure : bool;
-    [Accessor (flags = WantSetter)]
-    mutable ever_used : bool;
-    [Accessor (flags = WantSetter)]
-    mutable is_cache : bool;
-    [Accessor (flags = WantSetter)]
-    mutable is_managed_ptr : bool;
     mutable is_registered : bool;
     mutable closure_field : IField;
 
-    [Accessor (flags = WantSetter | Internal)]
-    mutable never_closurise : bool;
+    kind : Kind;
+    id   : int;
+
+    [Accessor] name       : string;
+    [Accessor] is_mutable : bool;
+    [Accessor] defined_in : Fun_header;
+    
+    [Accessor] mutable name_location : Location;
+    [Accessor] mutable used_in       : Set [Fun_header];
+
+    [Accessor (flags = WantSetter)]            mutable in_closure      : bool;
+    [Accessor (flags = WantSetter)]            mutable ever_used       : bool;
+    [Accessor (flags = WantSetter)]            mutable is_cache        : bool;
+    [Accessor (flags = WantSetter)]            mutable is_managed_ptr  : bool;
+    [Accessor (flags = WantSetter | Internal)] mutable never_closurise : bool;
 
     // Use of Kind.BlockReturn would be better,
     // but it results in error at Typer2.n line 746
     [Accessor (flags = WantSetter)]
     mutable expanded_block_return : bool;
 
-    mutable name_location : Location;
-    public NameLocation : Location
-    {
-      get { if (name_location == Location.Default) Location else name_location }
-    }
-
     [Nemerle.OverrideObjectEquals]
     public Equals (other : LocalValue) : bool {
       id == other.id
@@ -80,32 +67,27 @@
     public override GetHashCode () : int
     { id }
 
-    
     internal UseFrom (fh : Fun_header) : void
     {
       ever_used = true;
       used_in = used_in.Replace (fh);
     }
 
-
     public Type : TyVar
     {
       get { ty }
     }
 
-
     public ValKind : Kind
     {
       get { kind }
     }
 
-    
     public override ToString () : string
     {
       $ "$kind $(Name)"
     }
 
-
     public CompareTo (other : LocalValue) : int
     {
       id - other.id
@@ -124,13 +106,11 @@
       }
     }
 
-
     internal IsRegistered : bool
     {
       get { is_registered }
     }
 
-
     internal Register () : void
     {
       Util.cassert (!IsRegistered, this.ToString ());
@@ -145,7 +125,6 @@
       }
     }
 
-
     internal ClosureField : IField
     {
       get { closure_field }
@@ -155,7 +134,6 @@
       }
     }
 
-
     internal SetType (t : TyVar) : void
     {
       ty = t;
@@ -235,8 +213,8 @@
         else
           ILKind.Parm (idx)
     }
-    #endregion
 
+    #endregion
 
     
     public variant Kind
@@ -287,6 +265,9 @@
     public this (defined_in : Fun_header, name : string, name_location : Location,
                  ty : TyVar, kind : Kind, is_mutable : bool)
     {
+      unless (name_location.IsEmpty)
+        base(name_location);
+
       this.defined_in = defined_in;
       this.name = name;
       this.name_location = name_location;

Modified: nemerle/trunk/ncc/typing/TypedTree.n
==============================================================================
--- nemerle/trunk/ncc/typing/TypedTree.n	(original)
+++ nemerle/trunk/ncc/typing/TypedTree.n	Wed Jan 24 07:06:51 2007
@@ -621,7 +621,25 @@
     | Literal               { val : Nemerle.Compiler.Literal; }
     | This
     | Base                  { base_ctor : IMethod; }
-    | TypeConversion        { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
+    | TypeConversion        { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind;
+                              mutable target_type_location : Location;
+
+                              this(loc : Location, tv : TyVar, expr : TExpr, target_type : TyVar, kind : ConversionKind)
+                              {
+                                this(loc, tv, expr, target_type, kind, Location.Default);
+                              }
+
+                              this(tv : TyVar, expr : TExpr, target_type : TyVar, kind : ConversionKind)
+                              {
+                                this(tv, expr, target_type, kind, Location.Default);
+                              }
+
+                              this(expr : TExpr, target_type : TyVar, kind : ConversionKind)
+                              {
+                                this(expr, target_type, kind, Location.Default);
+                              }
+
+                            }
     | Sequence              { mutable e1 : TExpr; mutable e2 : TExpr; }
     | Tuple                 { args : list [TExpr]; }
     | Array                 { args : list [TExpr]; dimensions : list [TExpr]; }
@@ -1082,11 +1100,11 @@
           }
           Try (walk (f, body), cases.Map (walk_case))
 
-        | TypeConversion (expr, t, kind) =>
+        | TypeConversion (expr, t, kind, tl) =>
           def expr = null_walk (f, expr);
           if (expr == null) null
           else
-            TypeConversion (expr, t, kind)
+            TypeConversion (expr, t, kind, tl)
           
           
         | Sequence (e1, e2) =>

Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n	(original)
+++ nemerle/trunk/ncc/typing/Typer.n	Wed Jan 24 07:06:51 2007
@@ -1233,7 +1233,7 @@
             TExpr.Error ()
 
         | DefMutable (TypeEnforcement (nm, ty), val) =>
-          DoType (PT.PExpr.DefMutable (nm, PT.PExpr.TypeEnforcement (val, ty)),
+          DoType (PT.PExpr.DefMutable (nm, PT.PExpr.TypeEnforcement (ty.Location.Combine(val.Location), val, ty)),
                   expected, is_toplevel_in_seq)
         
         | DefMutable => Message.FatalError ($"incorrect mutable variables definition: $expression")
@@ -1430,11 +1430,11 @@
                            "block expects a simple identifier as a label")
           }
           
-        | PT.PExpr.TypeEnforcement (e, t) =>
-          def t = BindType (t);
+        | PT.PExpr.TypeEnforcement (e, ty) =>
+          def t = BindType (ty);
           if (Expect (expected, t, "type-enforcement body")) {
             def e = AddCastTo (TypeExpr (e), t, "type-enforced expression");
-            TExpr.TypeConversion (e, t, ConversionKind.UpCast ())
+            TExpr.TypeConversion (expression.Location, null, e, t, ConversionKind.UpCast (), ty.Location)
           } else
             TExpr.Error ()
 
@@ -1781,7 +1781,7 @@
                               LocalValue.Kind.Plain (), 
                               is_mutable);
       AddLocal (name, decl);
-      TExpr.DefValIn (decl, val, null)
+      TExpr.DefValIn (name_location.Combine(val.Location), null, decl, val, null)
     }
 
    

Modified: nemerle/trunk/ncc/typing/Typer2.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer2.n	(original)
+++ nemerle/trunk/ncc/typing/Typer2.n	Wed Jan 24 07:06:51 2007
@@ -275,7 +275,7 @@
       match (expr) {
         | TExpr.Delayed =>
           PushConversionDown (Unfold (expr))
-        | TExpr.TypeConversion (e, t, k) =>
+        | TExpr.TypeConversion (e, t, k, tl) =>
           if (k is ConversionKind.Implicit && 
               t.TryUnify (e.Type)) {
             t.ForceUnify (e.Type);
@@ -285,19 +285,19 @@
             match (e) {
               | DefValIn (n, v, b) =>
                 def b = VoidIfNull (b);
-                TExpr.DefValIn (e.ty, n, v, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k)))
+                TExpr.DefValIn (e.ty, n, v, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k, tl)))
 
               | DefFunctionsIn (funs, b) =>
                 def b = VoidIfNull (b);
-                TExpr.DefFunctionsIn (e.ty, funs, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k)))
+                TExpr.DefFunctionsIn (e.ty, funs, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k, tl)))
 
               | Sequence (e, b) =>
                 def b = VoidIfNull (b);
-                TExpr.Sequence (e.ty, e, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k)))
+                TExpr.Sequence (e.ty, e, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k, tl)))
 
               | Block (j, b) =>
                 def b = VoidIfNull (b);
-                TExpr.Block (e.ty, j, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k)))
+                TExpr.Block (e.ty, j, PushConversionDown (TExpr.TypeConversion (expr.ty, b, t, k, tl)))
 
               | Throw
               | Goto
@@ -748,7 +748,7 @@
     static StripImplicitConversion (expr : TExpr) : TExpr
     {
       match (expr) {
-        | TExpr.TypeConversion (e, _, ConversionKind.Implicit) => e
+        | TExpr.TypeConversion (e, _, ConversionKind.Implicit, _) => e
         | e => e
       }
     }
@@ -1273,14 +1273,14 @@
           null
           
 
-        | TExpr.TypeConversion (expr, t, ConversionKind.UpCast)
+        | TExpr.TypeConversion (expr, t, ConversionKind.UpCast, _)
           when t.Equals (InternalType.Void) && expr.Type.TryUnify (InternalType.Void)
-        | TExpr.TypeConversion (expr, _, ConversionKind.IgnoreValue)
+        | TExpr.TypeConversion (expr, _, ConversionKind.IgnoreValue, _)
           when expr.Type.TryUnify (InternalType.Void) =>
           expr.Type.ForceUnify (InternalType.Void);
           Walk (ctx, expr)
         
-        | TExpr.TypeConversion (expr, t, kind) =>
+        | TExpr.TypeConversion (expr, t, kind, _) =>
           BuildConversion (Walk (expr), t, kind)
           
           

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	Wed Jan 24 07:06:51 2007
@@ -22,21 +22,10 @@
     mutable _texprLocation : Location;
     mutable _stop          : bool;
 
-    PExprName : string
-    {
-      get { if (_pexprObject == null) null else _pexprObject.ToString() }
-    }
-
-    IgnorePExpr(obj : object) : bool
-    {
-      match (obj)
-      {
-      | PExpr.Wildcard as wc => wc.Location == _pexprLocation
-      | PExpr.Sequence
-      | PExpr.Is             => true
-      | _                    => false
-      }
-    }
+    //PExprName : string
+    //{
+    //  get { if (_pexprObject == null) null else _pexprObject.ToString() }
+    //}
 
     PFinder(info : ExprWalkInfo) : void
     {
@@ -44,13 +33,11 @@
       {
         def loc = (info.Node :> Located).Location;
 
-        when (IsIn(loc))
-        {
           Print(info.Node, loc, info.Nodes.Length);
 
-          when (!IgnorePExpr(info.Node))
+        when (IsIn(loc))
           {
-            when (_pexprObject == null || _pexprLocation.Intersect(loc) == loc)
+          when (_pexprObject == null || _pexprLocation.Contains(loc))
             {
               PrintAdd(info.Nodes.Length);
 
@@ -67,123 +54,100 @@
           }
         }
       }
-    }
     
     GetPattern(pattern : Pattern) : object
     {
-    | Application(name, _) =>      // { name : TypeInfo; arg : Pattern; }
-
-      def dt = name.DeclaringType;
-      if (dt != null && dt.Name == PExprName) dt else name
-
-    | HasType(typ)         =>      // { typ : MType; }
-
-        match (typ)
-        {
-        | Class(tycon, _) =>
-
-          def dt = tycon.DeclaringType;
-          if (dt != null && dt.Name == PExprName) dt else typ : object
-
-        | _ => typ
-        }
-
-    | As      (_, decl)    => decl // { pat : Pattern; decl : LocalValue; }
+//    | Application(name, _) =>      // { name : TypeInfo; arg : Pattern; }
+//
+//      def dt = name.DeclaringType;
+//      if (dt != null && dt.Name == PExprName) dt else name
+//
+//    | HasType(typ)         =>      // { typ : MType; }
+//
+//        match (typ)
+//        {
+//        | Class(tycon, _) =>
+//
+//          def dt = tycon.DeclaringType;
+//          if (dt != null && dt.Name == PExprName) dt else typ : object
+//
+//        | _ => typ
+//        }
+//
+//    | As      (_, decl)    => decl // { pat : Pattern; decl : LocalValue; }
     | _                    => pattern
     }
 
     GetExpr(expression : TExpr) : object
     {
-    | StaticRef(from, mem, _)          =>      // { from : MType.Class; mem : IMember; type_parms : list [TyVar]; }
-
-      if (mem.MemberKind != MemberKinds.Constructor && from.tycon.Name == PExprName)
-        from
-      else
-        mem : object
-
-    | TypeConversion(_, tt, _)         =>      // { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
-
-      if (tt.IsFixed)
-      {
-        match (tt.FixedValue)
-        {
-        | Class(tycon, _) =>
-
-          def dt = tycon.DeclaringType;
-          if (dt != null && dt.Name == PExprName) dt else tt : object
-
-        | _ => tt
-        }
-      }
-      else
-        tt
-
-    | Literal(Enum(value, ty, null))   => 
-
-      def members = ty.GetMembers();
-      def field   = members.Find(f =>
-      {
-        match (f)
-        {
-        | f is IField when f.IsStatic && f.IsLiteral =>
-
-          match (f.GetValue())
-          {
-          | Integer as val
-          | Literal.Enum(val, _, _) => val.ToString() == value.ToString()
-          | _ => false
-          }
+    | DefValIn      (name, _, _)     when IsIn(name.NameLocation) => name;
+    | TypeConversion(_, ty, _, tloc) when IsIn(tloc)              => ty : object;
 
-        | _ => false
-        }
-      });
-
-      match (field)
-      {
-      | Some(f) => f
-      | None    => expression : object
-      }
-
-    | Literal(Enum(_, _, field))       => field
-
-    | ConstantObjectRef(_, o : object)         // { from : MType.Class; mem : IField; }
-    | StaticPropertyRef(_, o : object)         // { from : MType.Class; prop : IProperty; }
-    | StaticEventRef   (_, o : object)         // { from : MType.Class; ev : IEvent; }
-    | Base                (o : object)         // { base_ctor : IMethod; }
-    | LocalFunRef         (o : object, _)      // { decl : LocalValue; type_parms : list [TyVar]; }
-    | LocalRef            (o : object)         // { decl : LocalValue; }
-    | MethodRef        (_, o : object, _, _)   // { obj : TExpr; meth : IMethod; type_parms : list [TyVar]; notvirtual : bool; }
-    | EventMember      (_, o : object)         // { obj : TExpr; ev : IEvent; }
-    | FieldMember      (_, o : object)         // { obj : TExpr; fld : IField; }
-    | PropertyMember   (_, o : object)         // { obj : TExpr; prop : IProperty; }
-    | DefValIn            (o : object, _, _)   // { name : LocalValue; val : TExpr; mutable body : TExpr; }
-    | HasType          (_, o : object)         // { expr : TExpr; test_ty : MType; }
-    | TypeOf              (o : object) => o    // { target_type : TyVar; }
-    | _                                => expression
-    }
-
-    IgnoreTExpr(obj : object) : bool
-    {
-      match (obj)
-      {
-      | pat is Pattern => match (pat)
-        {
-        | Wildcard => pat.ToString() != PExprName
-        | Record   => _texprObject is Pattern.Application
-        | HasType  => _texprObject is Pattern.As && (_texprObject :> Pattern.As).decl.Name == PExprName
-        | _        => false
-        }
-      | expr is TExpr  => match (expr)
-        {
-        | LocalRef(LocalValue where (ValKind = ClosurisedThisPointer)) => expr.Location == _texprLocation
-        | TypeConversion => true
-        | Literal        => expr.ToString() != PExprName
-//        | StaticRef      => _texprObject is TExpr.Call
-        | Error          => true
-        | _              => false
-        }
-      | _ => false
-      }
+    //| StaticRef(from, mem, _)          =>      // { from : MType.Class; mem : IMember; type_parms : list [TyVar]; }
+//
+      //if (mem.MemberKind != MemberKinds.Constructor && from.tycon.Name == PExprName)
+        //from
+      //else
+        //mem : object
+//
+    //| TypeConversion(_, tt, _)         =>      // { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
+//
+      //if (tt.IsFixed)
+      //{
+        //match (tt.FixedValue)
+        //{
+        //| Class(tycon, _) =>
+//
+          //def dt = tycon.DeclaringType;
+          //if (dt != null && dt.Name == PExprName) dt else tt : object
+//
+        //| _ => tt
+        //}
+      //}
+      //else
+        //tt
+//
+    //| Literal(Enum(value, ty, null))   => 
+//
+      //def members = ty.GetMembers();
+      //def field   = members.Find(f =>
+      //{
+        //match (f)
+        //{
+        //| f is IField when f.IsStatic && f.IsLiteral =>
+//
+          //match (f.GetValue())
+          //{
+          //| Integer as val
+          //| Literal.Enum(val, _, _) => val.ToString() == value.ToString()
+          //| _ => false
+          //}
+//
+        //| _ => false
+        //}
+      //});
+//
+      //match (field)
+      //{
+      //| Some(f) => f
+      //| None    => expression : object
+      //}
+//
+    //| Literal(Enum(_, _, field))       => field
+//
+    //| ConstantObjectRef(_, o : object)         // { from : MType.Class; mem : IField; }
+    //| StaticPropertyRef(_, o : object)         // { from : MType.Class; prop : IProperty; }
+    //| StaticEventRef   (_, o : object)         // { from : MType.Class; ev : IEvent; }
+    //| Base                (o : object)         // { base_ctor : IMethod; }
+    //| LocalFunRef         (o : object, _)      // { decl : LocalValue; type_parms : list [TyVar]; }
+    //| LocalRef            (o : object)         // { decl : LocalValue; }
+    //| MethodRef        (_, o : object, _, _)   // { obj : TExpr; meth : IMethod; type_parms : list [TyVar]; notvirtual : bool; }
+    //| EventMember      (_, o : object)         // { obj : TExpr; ev : IEvent; }
+    //| FieldMember      (_, o : object)         // { obj : TExpr; fld : IField; }
+    //| PropertyMember   (_, o : object)         // { obj : TExpr; prop : IProperty; }
+    //| HasType          (_, o : object)         // { expr : TExpr; test_ty : MType; }
+    //| TypeOf              (o : object) => o    // { target_type : TyVar; }
+    | _                                => null : object
     }
 
     TFinder(info : ExprWalkInfo) : void
@@ -199,50 +163,19 @@
 
         def loc = (info.Node :> Located).Location;
 
-        when (IsIn(loc))
-        {
           Print(info.Node, loc, info.Nodes.Length);
 
-          when (
-            if      (_texprObject == null)  true
-            else if (loc == _texprLocation) !IgnoreTExpr(info.Node)
-            else 
-               loc == _pexprLocation ||
-               loc == _texprLocation.Intersect(loc)
-          )
+        when (IsIn(loc))
+        {
+          when (_texprObject == null || loc == _pexprLocation || _texprLocation.Contains(loc))
           {
             PrintAdd(info.Nodes.Length);
 
             _texprLocation = loc;
             _texprObject   = info.Node;
 
-            when (_texprObject is TExpr)
-            {
-              if (loc == _pexprLocation)
-              {
-                match (_texprObject :> TExpr)
-                {
-                | MethodRef     (_, meth, _, _) when meth.Name == PExprName
-                | FieldMember   (_, fld)        when fld. Name == PExprName
-                | PropertyMember(_, prop)       when prop.Name == PExprName
-                | EventMember   (_, ev)         when ev.  Name == PExprName
-                | MacroEnvelope => info.Stop();
-                | _ => ()
-                }
-              }
-              else
-              {
-                match (_texprObject :> TExpr)
-                {
-                | MacroEnvelope(Call(Ref(name) as r, _), _, _)
-                    when name.Id == PExprName && r.Location == _pexprLocation =>
-
+            when (loc == _pexprLocation)
                   info.Stop();
-
-                | _ => ()
-                }
-              }
-            }
           }
         }
 
@@ -301,12 +234,14 @@
       _col           = col;
       _stop          = false;
       _pexprObject   = null;
+      _pexprLocation = Location.Default;
       _texprObject   = null;
+      _texprLocation = Location.Default;
     }
 
     IsIn(location : Location) : bool
     {
-      location.Contains(_line, _col);
+      !location.IsGenerated && location.Contains(_line, _col);
     }
     
     Print(obj : object, loc : Location, level : int) : void
@@ -350,8 +285,9 @@
       ignore(level);
     }
 
-    _debug[T](o : T) : void
+    _debug(o : object) : void
     {
+      when (o != null)
       _ = o.ToString();
     }
   }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	Wed Jan 24 07:06:51 2007
@@ -378,7 +378,7 @@
         | PropertyMember(e, _)                                  // { obj : TExpr; prop : IProperty; }
         | FieldMember   (e, _)                                  // { obj : TExpr; fld : IField; }
         | EventMember   (e, _)                                  // { obj : TExpr; ev : IEvent; }
-        | TypeConversion(e, _, _)                               // { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
+        | TypeConversion(e, _, _, _)                            // { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; target_type_location : Location; }
         | MacroEnvelope (_, _, e)                               // { original : Parsetree.PExpr; the_macro : IMacro; expanded : TExpr; }
         | MethodRef     (e, _, _, _) => Go(e);                  // { obj : TExpr; meth : IMethod; type_parms : list [TyVar]; notvirtual : bool; }
         | ArrayIndexer  (e, lst)     => Go(e); Go(lst);         // { obj : TExpr; args : list [TExpr]; }
@@ -498,6 +498,12 @@
         }
       });
     }
+
+    _debug(o : object) : void
+    {
+      when (o != null)
+        _ = o.ToString();
+    }
   }
 }
 

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n	Wed Jan 24 07:06:51 2007
@@ -485,7 +485,7 @@
       | TExpr.Base =>                 // base_ctor : IMethod; }
         CodeBaseReferenceExpression()
 
-      | TExpr.TypeConversion(expr,target_type,_) => // mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
+      | TExpr.TypeConversion(expr,target_type,_,_) => // mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; target_type_location : Location; }
         CodeCastExpression(target_type.SystemType, CreateExpression(expr)) // TODO: what about kind?
 
       /*



More information about the svn mailing list