diff options
| author | Rich Hickey <richhickey@gmail.com> | 2006-04-21 20:21:59 +0000 |
|---|---|---|
| committer | Rich Hickey <richhickey@gmail.com> | 2006-04-21 20:21:59 +0000 |
| commit | a42245c3e9c1cf2c2e54dc31c7bffd91ae32dac8 (patch) | |
| tree | 16e579a97f4a87a860782cf56c7e937bf2b2c931 /src/cli/runtime/Keyword.cs | |
| parent | 165da010e2c81bab2128231384128b39b7c9a127 (diff) | |
revised symbol system
Diffstat (limited to 'src/cli/runtime/Keyword.cs')
| -rw-r--r-- | src/cli/runtime/Keyword.cs | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/cli/runtime/Keyword.cs b/src/cli/runtime/Keyword.cs index 8748cdf1..6e1bf33b 100644 --- a/src/cli/runtime/Keyword.cs +++ b/src/cli/runtime/Keyword.cs @@ -11,39 +11,21 @@ /* rich Mar 29, 2006 10:39:05 AM */ using System;
+using System.Collections.Specialized;
namespace org.clojure.runtime
{ -public class Keyword : Symbol
+public class Keyword : Indexer
{ -/** - * Used by Namespace.intern() - * - * @param name - * @param ns - */ -internal Keyword(String name, Namespace ns): - base(name, ns) - - { - this.val = this; - this.fn = this; - } - -override public Object getValue(ThreadLocalData tld) - { - return this; - } +static public HybridDictionary table = new HybridDictionary(); -override public Object setValue(ThreadLocalData tld, Object val) - { - throw new InvalidOperationException("Cannot set the value of a keyword"); - } -override public String ToString() +public String name;
override public String ToString() { return ":" + name; } +
public static Keyword intern(String name)
{
lock(table)
{
Keyword sym = (Keyword) table[name];
if(sym == null)
table.Add(name, sym = new Keyword(name));
return sym;
}
}
/**
* Used by Namespace.intern()
*
* @param name
*/
Keyword(String name)
{
this.name = name;
}
/**
* Indexer implements IFn for attr access
* This single arg version is the getter
* @param tld
* @param obj - must be AMap
* @return the value of the attr or nil if not found
*/
override public Object invoke(ThreadLocalData tld, Object obj) /*throws Exception*/
{
return ((AMap)obj).get(this);
}
/**
* Indexer implements IFn for attr access
* This two arg version is the setter
* @param tld
* @param obj - must be AMap
* @param val
* @return val
*/
override public Object invoke(ThreadLocalData tld, Object obj, Object val) /*throws Exception*/
{
return ((AMap)obj).put(this,val);
} + } }
\ No newline at end of file |
