[svn]
r6722: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2:
CompiledUnitAstBrowser.n Engine/E...
VladD2
svnadmin at nemerle.org
Wed Sep 27 03:48:18 CEST 2006
Log:
Work on relocation.
Author: VladD2
Date: Wed Sep 27 03:48:16 2006
New Revision: 6722
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n Wed Sep 27 03:48:16 2006
@@ -1,4 +1,5 @@
using System;
+using System.Reflection;
using System.Windows.Forms;
using Nemerle.Compiler;
using Nemerle.Compiler.Utils;
@@ -7,8 +8,70 @@
{
public delegate ShowLocation(_ : Location) : void;
+ variant PropInfo
+ {
+ | SimpleNode
+ {
+ name : string;
+ ty : Type;
+ loc : option[Location];
+ subNodes : list[PropInfo]
+ }
+
+ | LocationNode { name : string; loc : Location; }
+ | None
+ }
+
public class CompiledUnitAstBrowser : Form
{
+ static locTy : Type = typeof(Location);
+ static iterTy : Type = typeof(System.Collections.IEnumerable);
+
+ ScanVariable(name : string, obj : object) : PropInfo
+ {
+ def ty = obj.GetType();
+ //def locatedTy = typeof(Located);
+
+ if (ty.Equals(locTy))
+ PropInfo.LocationNode(name, obj :> Location);
+ else
+ {
+ mutable infos = [] : list[PropInfo];
+
+ foreach (field in ty.GetFields())
+ {
+ def value = field.GetValue(obj);
+
+ unless (value == null)
+ {
+ def valTy = value.GetType();
+
+ if (valTy.IsSubclassOf(iterTy))
+ {
+ mutable infos2 = [];
+ foreach (elem in value :> System.Collections.IEnumerable)
+ {
+ def res1 = ScanVariable("elem:", elem);
+ unless (res1 is PropInfo.None)
+ infos2 ::= res1;
+
+ infos ::= PropInfo.SimpleNode(name, ty, None(), infos2);
+ }
+ }
+ else
+ {
+ def res2 = ScanVariable(field.Name, value);
+ unless (res2 is PropInfo.None)
+ infos ::= res2;
+ }
+ }
+ }
+
+ PropInfo.SimpleNode(name, ty, None(), infos)
+ }
+ }
+
+
FillTree(root : Decl) : void
{
def fileIndex = root.Location.FileIndex;
@@ -80,8 +143,22 @@
foreach (member in fileMembers)
{
+ def info = ScanVariable($"$member", member);
+ _ = info;
addLocation(nodes, member.ToString(), " ", member.Location);
- addLocation(currNode.Nodes, "BodyLocation", " ", member.BodyLocation);
+ def nodes2 = currNode.Nodes;
+ addLocation(nodes2, "BodyLocation", " ", member.BodyLocation);
+ match (member)
+ {
+ | method is MethodBuilder =>
+ def header = method.GetHeader();
+ addLocation(nodes2, "header", " ", header.Location);
+ def headerNodes = currNode.Nodes;
+ foreach (parm in header.parms)
+ addLocation(headerNodes, "parm", parm.ToString(), parm.loc);
+
+ | _ => ()
+ }
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n Wed Sep 27 03:48:16 2006
@@ -25,7 +25,6 @@
private BuildTypesTreeAndInitProject() : void
{
Trace.WriteLine("### Build types tree!");
- ClearRelocationMaps();
ClearCompilerMessages();
Instance = this;
Init();
@@ -53,11 +52,6 @@
trees ::= decls;
}
finally { EndParseFile(_fileIndex); }
- //| Parsed as p =>
- // foreach (decl is TopDeclaration.Delegate in p.decls)
- // decl.Attributes &= ~NemerleAttributes.Sealed;
-
- // trees ::= p.decls;
}
}
@@ -124,13 +118,6 @@
_project = Project(this, CompileUnitCollection(this, _fileInfos), nsTree);
}
- protected ClearRelocationMaps() : void
- {
- def map = Location.RelocationMaps;
- for (mutable i = 0; i < map.Count; i++)
- map[i] = null;
- }
-
public RunCompletionEngine (
[NotNull] method : MethodBuilder,
[NotNull] content : string,
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Init.n Wed Sep 27 03:48:16 2006
@@ -27,7 +27,6 @@
{
options.GreedyReferences = false;
base (options);
- Location.IsUseRelocationMaps = true;
Output = output;
_state = EngineState.Pure;
_isInCompletionMode = true;
More information about the svn
mailing list