summaryrefslogtreecommitdiff
path: root/src/cli/runtime/Module.cs
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-09-25 17:54:37 +0000
committerRich Hickey <richhickey@gmail.com>2006-09-25 17:54:37 +0000
commit51c468f878a842bc6e469c32acbc58543448d081 (patch)
tree269d7766024da9e03a4f15e255c3c73ef8289b93 /src/cli/runtime/Module.cs
parent987dad567505261e0daf3dcbdd6363353cbe15a5 (diff)
renamed Namespace to Module
Diffstat (limited to 'src/cli/runtime/Module.cs')
-rw-r--r--src/cli/runtime/Module.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/cli/runtime/Module.cs b/src/cli/runtime/Module.cs
new file mode 100644
index 00000000..e2c091fe
--- /dev/null
+++ b/src/cli/runtime/Module.cs
@@ -0,0 +1,63 @@
+/**
+ * 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 27, 2006 1:29:39 PM */
+
+using System;
+using System.Collections.Specialized;
+
+namespace clojure.lang
+{
+
+public class Module
+{
+
+/**
+ * String->Module
+ */
+static public HybridDictionary table = new HybridDictionary();
+
+/**
+ * Symbol->Var
+ */
+public HybridDictionary vars = new HybridDictionary();
+public String name;
+
+
+Module(String name)
+ {
+ this.name = name;
+ table.Add(name, this);
+ }
+
+static public Module find(String name)
+ {
+ return (Module) table[name];
+ }
+
+static public Module findOrCreate(String name)
+ {
+ lock(table)
+ {
+ Module ns = find(name);
+ if(ns == null)
+ table.Add(name,ns = new Module(name));
+ return ns;
+ }
+ }
+
+static public Var intern(String ns, String name)
+ {
+ return findOrCreate(ns).intern(Symbol.intern(name));
+ }
+
+public Var intern(Symbol sym) { lock(vars) { Var var = (Var) vars[sym]; if(var == null) vars.Add(sym,var = new Var(sym, this)); return var; } }
+}
+}