blob: 1a72b60e175711027456ddf43babcce0adc6db69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/**
* Copyright (c) Rich Hickey. All rights reserved.
* The use and distribution terms for this software are covered by the
* Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
* which can be found in the file CPL.TXT at the root of this distribution.
* By using this software in any fashion, you are agreeing to be bound by
* the terms of this license.
* You must not remove this notice, or any other, from this software.
**/
/* rich Mar 25, 2006 11:42:47 AM */
using System;
using System.Collections;
namespace clojure.lang
{
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);
public readonly String name;
//int hash = 0;
override public String ToString()
{
return name;
}
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()
* @param name
* @param ns
*/
internal Symbol(String name)
{
this.name = name;
}
/*
public override int GetHashCode()
{
if(hash == 0)
{
lock (hashes)
{
while (hash == 0)
{
int h = rand.Next();
if (h != 0 && !hashes.ContainsKey(h))
{
hash = h;
hashes.Add(h,null);
}
}
}
}
return hash;
}
#region IComparable Members
public int CompareTo(object obj)
{
return GetHashCode() - ((Symbol)obj).GetHashCode();
}
#endregion
override public Obj withMeta(IPersistentMap meta) {
this._meta = meta;
return this;
}
*/
}
}
|