[svn] r6519: nemerle/trunk: lib/tree.n ncc/hierarchy/GlobalEnv.n
ncc/hierarchy/MacroClassGen.n ncc/hierarc...
VladD2
svnadmin at nemerle.org
Mon Aug 14 11:46:38 CEST 2006
Log:
1. Change name of property GlobalEnv.Name to FullName and add Name property which return value of field name.
2. Working on completion of namespace in method body.
Author: VladD2
Date: Mon Aug 14 11:46:23 2006
New Revision: 6519
Modified:
nemerle/trunk/lib/tree.n
nemerle/trunk/ncc/hierarchy/GlobalEnv.n
nemerle/trunk/ncc/hierarchy/MacroClassGen.n
nemerle/trunk/ncc/hierarchy/NamespaceTree.n
nemerle/trunk/ncc/hierarchy/TypeBuilder.n
nemerle/trunk/ncc/misc/PrettyPrint.n
nemerle/trunk/ncc/parsing/Lexer.n
nemerle/trunk/ncc/parsing/MainParser-Extensions.n
nemerle/trunk/ncc/typing/MacroRegistry.n
nemerle/trunk/ncc/typing/Macros.n
nemerle/trunk/ncc/typing/OverloadPossibility.n
nemerle/trunk/ncc/typing/Typer.n
Modified: nemerle/trunk/lib/tree.n
==============================================================================
--- nemerle/trunk/lib/tree.n (original)
+++ nemerle/trunk/lib/tree.n Mon Aug 14 11:46:23 2006
@@ -639,13 +639,19 @@
/* definition of Map class */
- public class Map ['a, 'b]
+ public class Map ['a, 'b] : SCG.IEnumerable ['a * 'b]
// : IMap ['a, 'b]
where 'a : System.IComparable ['a]
{
private root : Tree.Node [NodeNem ['a, 'b]];
private size : int;
+ public GetEnumerator () : SCG.IEnumerator ['a * 'b]
+ {
+ foreach (elem in root)
+ yield (elem.key, elem.val)
+ }
+
// TODO : Make it implement ICollection (problem with names and being functional or imperative - both mb)
public this ()
Modified: nemerle/trunk/ncc/hierarchy/GlobalEnv.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/GlobalEnv.n (original)
+++ nemerle/trunk/ncc/hierarchy/GlobalEnv.n Mon Aug 14 11:46:23 2006
@@ -422,7 +422,7 @@
def nodes = List.FoldLeft (added, old, fun (x : NamespaceTree.Node, acc) {
if (List.ContainsRef (old, x)) {
when (should_warn)
- Message.Warning (105, loc, $ @"namespace `$(x.Name.ToString ("".""))' is already open");
+ Message.Warning (105, loc, $ @"namespace `$(x.GetDisplayName ())' is already open");
acc
}
else {
@@ -532,14 +532,14 @@
if (x.IsFromAlias)
acc
else
- x.Name.ToString (".") :: acc
+ x.GetDisplayName () :: acc
};
def aliases = List.Sort (List.RevMap (namespace_aliases, collect), String.CompareOrdinal);
def spaces = List.Sort (List.FoldLeft (open_namespaces, [], extract), String.CompareOrdinal);
def coded_al = aliases.ToString ("#");
def coded_ns = spaces.ToString ("#");
- def coded = Text.StringBuilder (current_namespace.Name.ToString (".") + "&");
+ def coded = Text.StringBuilder (current_namespace.GetDisplayName () + "&");
ignore (coded.Append (coded_ns + "&"));
ignore (coded.Append (coded_al + "&"));
match (nameTree.macro_contexts.Get (coded.ToString ())) {
@@ -556,9 +556,7 @@
public override ToString () : string
{
-// def openns = List.Map (open_namespaces, fun (x : NamespaceTree.Node) {
-// Util.qid_of_list (x.Name) });
- "GlobalEnv(" + current_namespace.Name.ToString (".") + ": " + ")"
+ "GlobalEnv(" + current_namespace.GetDisplayName () + ": " + ")"
}
}
}
Modified: nemerle/trunk/ncc/hierarchy/MacroClassGen.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/MacroClassGen.n (original)
+++ nemerle/trunk/ncc/hierarchy/MacroClassGen.n Mon Aug 14 11:46:23 2006
@@ -534,7 +534,7 @@
public GetName () : string { $(retname : string) }
public GetNamespace () : string {
- $(Util.QidOfList (ns_node.Name) : string)
+ $(ns_node.GetDisplayName () : string)
}
}
]>);
Modified: nemerle/trunk/ncc/hierarchy/NamespaceTree.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/NamespaceTree.n (original)
+++ nemerle/trunk/ncc/hierarchy/NamespaceTree.n Mon Aug 14 11:46:23 2006
@@ -55,7 +55,7 @@
public Parent : Node;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
- name : string; // the same as edge from parent to this
+ [Accessor] name : string; // the same as edge from parent to this
public mutable Value : TypeInfoCache;
@@ -95,13 +95,13 @@
else unchecked ((Parent.GetHashCode () * 7) ^ name.GetHashCode ())
}
- protected GetDisplayName () : string
+ public GetDisplayName () : string
{
- Name.ToString(".")
+ FullName.ToString(".")
}
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
- public Name : list [string]
+ public FullName : list [string]
{
get {
if (name == null) ["alias"]
@@ -345,7 +345,7 @@
internal CleanUp () : void
{
- when (this.Name is ["alias"])
+ when (this.FullName is ["alias"])
this.Clear ();
this.Value = TypeInfoCache.No ();
}
@@ -387,7 +387,7 @@
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
_node : NamespaceTree.Node;
- public Name : string { get { _node.Name.ToString(".") } }
+ public Name : string { get { _node.GetDisplayName () } }
public Children : array [NamespaceTree.Node]
{
@@ -397,7 +397,7 @@
array (0)
else
_node.Children.Values.ToArray().SortInplace((x, y) =>
- x.Name.ToString(".").CompareTo(y.Name.ToString(".")))
+ x.Name.CompareTo(y.Name))
}
}
}
@@ -514,10 +514,10 @@
ns.Value = TypeInfoCache.MacroCall (m)
| TypeInfoCache.NamespaceReference =>
- Message.Error ("cannot define `" + ns.Name.ToString (".") +
+ Message.Error ("cannot define `" + ns.GetDisplayName () +
"' because the same namespace exists ");
| _ =>
- Message.Error ("redefinition of `" + ns.Name.ToString (".") + "'");
+ Message.Error ("redefinition of `" + ns.GetDisplayName () + "'");
}
}
@@ -525,7 +525,7 @@
internal LookupInternalType (name : list[string]) : TypeInfo {
match (LookupExactType (name)) {
| Some (t) => t
- | None => Util.ice ("unbound internal type " + name.ToString ("."))
+ | None => Util.ice ("unbound internal type " + name.ToString("."))
}
}
@@ -581,8 +581,8 @@
| _ => scream = false
}
when (scream) {
- Message.Error (loc, "referenced namespace `" +
- all_opened.Last.Name.ToString (".")
+ Message.Error (loc, "referenced namespace `"
+ + all_opened.Last.GetDisplayName ()
+ "' does not exist")
}
}
Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n (original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n Mon Aug 14 11:46:23 2006
@@ -1,4 +1,4 @@
-/*
+ /*
* Copyright (c) 2003-2005 The University of Wroclaw.
* All rights reserved.
*
@@ -99,7 +99,7 @@
internal this (manager : TypesManager, par : TypeBuilder, td : PT.TopDeclaration,
ns_node : NamespaceTree.Node)
{
- base (ns_node, manager.Manager, ns_node.Name.ToString ("."));
+ base (ns_node, manager.Manager, ns_node.GetDisplayName ());
this.TyManager = manager;
Modified: nemerle/trunk/ncc/misc/PrettyPrint.n
==============================================================================
--- nemerle/trunk/ncc/misc/PrettyPrint.n (original)
+++ nemerle/trunk/ncc/misc/PrettyPrint.n Mon Aug 14 11:46:23 2006
@@ -353,7 +353,7 @@
parms_left = xs;
| _ =>
Message.Error ("expected raw token as parameter of macro "
- + Util.QidOfList (namespc.Name))
+ + namespc.GetDisplayName ())
};
| GrammarElement.Expression =>
@@ -363,7 +363,7 @@
parms_left = xs;
| _ =>
Message.Error ("expected expression as parameter of macro "
- + Util.QidOfList (namespc.Name) + " got " +
+ + namespc.GetDisplayName () + " got " +
parms_left.ToString ())
};
| GrammarElement.Parameter =>
@@ -373,7 +373,7 @@
parms_left = xs;
| _ =>
Message.Error ("expected function parameter as parameter of macro "
- + Util.QidOfList (namespc.Name))
+ + namespc.GetDisplayName ())
};
| GrammarElement.ExpressionList =>
@@ -381,7 +381,7 @@
| SyntaxElement.Expression (e) => SprintExpr (ctx, e, indentation, acc)
| _ =>
Message.Error ("expected expression in macro parameters: "
- + Util.QidOfList (namespc.Name))
+ + namespc.GetDisplayName ())
}, acc);
| GrammarElement.Branch | GrammarElement.End => Util.ice ("invalid node");
Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n (original)
+++ nemerle/trunk/ncc/parsing/Lexer.n Mon Aug 14 11:46:23 2006
@@ -121,7 +121,7 @@
PreParser.Dump (this, "")
| Namespace (env, body) =>
- "namespace " + env.CurrentNamespace.Name.ToString (".")
+ "namespace " + env.CurrentNamespace.GetDisplayName ()
+ " { " + PreParser.Dump (body, "") + " }"
| Using => "using import;"
Modified: nemerle/trunk/ncc/parsing/MainParser-Extensions.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser-Extensions.n (original)
+++ nemerle/trunk/ncc/parsing/MainParser-Extensions.n Mon Aug 14 11:46:23 2006
@@ -120,8 +120,7 @@
| Optional (body) => body.ToString () + "?"
| RawToken => "Token"
| Branch (opts) => "(" + List.Map (opts, fun (x) { $"`$(x)'" }).ToString (" | ") + ")"
-
- | End (d) => d.MacroNamespace.Name.ToString (".")
+ | End (d) => d.MacroNamespace.GetDisplayName ()
}
}
}
Modified: nemerle/trunk/ncc/typing/MacroRegistry.n
==============================================================================
--- nemerle/trunk/ncc/typing/MacroRegistry.n (original)
+++ nemerle/trunk/ncc/typing/MacroRegistry.n Mon Aug 14 11:46:23 2006
@@ -124,7 +124,7 @@
}
expand_macro (ctx, expanded)
| _ =>
- Util.ice ("failed to resolve macro name `" + namespc.Name.ToString (".") + "'")
+ Util.ice ("failed to resolve macro name `" + namespc.GetDisplayName () + "'")
}
| _ => expr
@@ -163,7 +163,7 @@
None ()
| _ =>
- Util.ice ("failed to resolve macro name `" + ns.Name.ToString (".") + "'")
+ Util.ice ("failed to resolve macro name `" + ns.GetDisplayName () + "'")
}
| _ => None ()
Modified: nemerle/trunk/ncc/typing/Macros.n
==============================================================================
--- nemerle/trunk/ncc/typing/Macros.n (original)
+++ nemerle/trunk/ncc/typing/Macros.n Mon Aug 14 11:46:23 2006
@@ -720,7 +720,7 @@
};
assert (name.context != null);
<[ PExpr.MacroCall ($(quoted_name (name, name.context.GetMacroContext ())),
- ManagerClass.Instance.NameTree.ExactPath ($(Lift (namespc.Name, Lift))),
+ ManagerClass.Instance.NameTree.ExactPath ($(Lift (namespc.FullName, Lift))),
$(Lift (parms, quoted_syntax))) ]>
| PExpr.Error => <[ PExpr.Error () ]>
Modified: nemerle/trunk/ncc/typing/OverloadPossibility.n
==============================================================================
--- nemerle/trunk/ncc/typing/OverloadPossibility.n (original)
+++ nemerle/trunk/ncc/typing/OverloadPossibility.n Mon Aug 14 11:46:23 2006
@@ -183,9 +183,7 @@
is_static = true
else
match (member) {
- | meth is IMethod =>
- is_static =
- meth.GetFunKind () is FunKind.Constructor
+ | meth is IMethod => is_static = meth.GetFunKind () is FunKind.Constructor
| _ => {}
}
@@ -195,7 +193,9 @@
assert ((from == null) != is_static,
$ "from/IsStatic $member $(member.IsStatic) $is_static");*/
+ when (ty != null)
this.solver = ty.Manager.Solver;
+
this.expr = expr;
this.from = from;
this.member = member;
@@ -424,4 +424,16 @@
public override ToString () : string { Value.ToString () }
}
+
+ [Record]
+ public class NamespaceCompletionPossibility : OverloadPossibility {
+ public IsAlias : bool;
+ public NameOrAlias : string;
+ public FullName : string;
+
+ public override ToString () : string
+ {
+ (if (IsAlias) "alias: " else "") + $"$NameOrAlias ($FullName)"
+ }
+ }
}
Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n (original)
+++ nemerle/trunk/ncc/typing/Typer.n Mon Aug 14 11:46:23 2006
@@ -1392,6 +1392,8 @@
| PT.PExpr.Member (obj, PT.Splicable.HalfId (name)) =>
+ def obj = obj;
+ def name = name;
def skip_name =
! CanBeTypeName (obj) ||
try {
@@ -1418,17 +1420,38 @@
throw compl_exc
| PT.PExpr.ToComplete (name) =>
- def overloads =
- TypeNameFull (expression, expected, for_completion = true);
+ def prefix = name.Id;
+ def builder = CurrentMethodBuilder;
+ mutable overloads = TypeNameFull (expression, expected, for_completion = true);
- def overloads = local_context.Fold (overloads, fun (locname, x, acc) {
- if (locname.Id.StartsWith (name.Id))
- LocalValueCompletionPossibility (this, x.Type, null, null, CurrentMethodBuilder, null, x) :: acc
- else
- acc
- });
+ // find locals
+ foreach ((name, local) when name.Id.StartsWith (prefix) in local_context.GetLocals ())
+ overloads ::= LocalValueCompletionPossibility (
+ this, local.Type, null, null, builder, null, local);
+
+ // find namespaces
+
+ def find_namespaces (ns, processParent)
+ {
+ when (ns != null)
+ {
+ when (ns.Children != null)
+ foreach ((name, subNs) in ns.Children.KeyValuePairs)
+ when (subNs.Value is NamespaceTree.TypeInfoCache.NamespaceReference && name.StartsWith (prefix))
+ overloads ::= NamespaceCompletionPossibility (
+ this, null, null, null, CurrentMethodBuilder, null, false, name, subNs.GetDisplayName ());
+
+ when (processParent)
+ find_namespaces (ns.Parent, processParent)
+ }
+ }
+
+ find_namespaces (env.CurrentNamespace.Parent, true);
+
+ foreach (ns in env.OpenNamespaces)
+ find_namespaces (ns, false);
- throw CompletionResult (overloads, name.Id)
+ throw CompletionResult (overloads, prefix)
| PT.PExpr.Member (_, _) =>
More information about the svn
mailing list