From 86fcd18f4ef4d0cfc17df28649ae10b5060f2432 Mon Sep 17 00:00:00 2001 From: Rich Hickey Date: Mon, 25 Sep 2006 18:46:24 +0000 Subject: reorg of host symbols --- src/cli/runtime/Symbol.cs | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src/cli/runtime/Symbol.cs') diff --git a/src/cli/runtime/Symbol.cs b/src/cli/runtime/Symbol.cs index c7dd6368..1a72b60e 100644 --- a/src/cli/runtime/Symbol.cs +++ b/src/cli/runtime/Symbol.cs @@ -15,25 +15,40 @@ using System.Collections; namespace clojure.lang { -public class Symbol : Obj, IComparable{ +public class Symbol +// : Obj, IComparable +{ static public readonly Hashtable table = new Hashtable(1001); -static public readonly Hashtable hashes = new Hashtable(1001); -static readonly Random rand = new Random(42); +//static public readonly Hashtable hashes = new Hashtable(1001); +//static readonly Random rand = new Random(42); public readonly String name; -int hash = 0; +//int hash = 0; override public String ToString() { return name; } -public static Symbol intern(String name) { lock(table) { Symbol sym = (Symbol) table[name]; if(sym == null) { if(name[0] == ':') sym = new Keyword(name); - else if (name[0] == '.') - sym = new Accessor(name); - else sym = new Symbol(name); if(table[name] != null) //defend against recursive static init +public static Symbol intern(String name) { lock(table) { Symbol sym = (Symbol) table[name]; + int dot = 0; + if (sym == null) + { + if (name[0] == ':') + sym = new Keyword(name); + else if ((dot = name.IndexOf('.')) != -1) + { + if (dot == 0) + sym = new InstanceMemberSymbol(name); + else if (name.LastIndexOf('.') == name.Length - 1) + sym = new ClassSymbol(name); + else + sym = new StaticMemberSymbol(name); + } + else + sym = new Symbol(name); if(table[name] != null) //defend against recursive static init return (Symbol)table[name]; table.Add(name, sym); } return sym; } } /** * Used by Module.intern() @@ -45,7 +60,7 @@ internal Symbol(String name) this.name = name; } - +/* public override int GetHashCode() { if(hash == 0) @@ -80,6 +95,6 @@ override public Obj withMeta(IPersistentMap meta) { this._meta = meta; return this; } - +*/ } } -- cgit v1.2.3-70-g09d2