summaryrefslogtreecommitdiff
path: root/src/cli/runtime/Symbol.cs
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-09-25 18:46:24 +0000
committerRich Hickey <richhickey@gmail.com>2006-09-25 18:46:24 +0000
commit86fcd18f4ef4d0cfc17df28649ae10b5060f2432 (patch)
tree80c3df20f1ea328545f94eefb4104c66e53612a8 /src/cli/runtime/Symbol.cs
parent51c468f878a842bc6e469c32acbc58543448d081 (diff)
reorg of host symbols
Diffstat (limited to 'src/cli/runtime/Symbol.cs')
-rw-r--r--src/cli/runtime/Symbol.cs35
1 files changed, 25 insertions, 10 deletions
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;
}
-
+*/
}
}