diff options
author | Rich Hickey <richhickey@gmail.com> | 2006-09-26 20:24:16 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2006-09-26 20:24:16 +0000 |
commit | 2212ddd3122b6f0799b4ed73e77aeeea7c19c34c (patch) | |
tree | e27e56585826a7717e3310410cf1f15df4970beb /src/cli | |
parent | bbabe65cbbbba066e2df174d7b7bea9b5739b8a5 (diff) |
interim checkin
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/runtime/Module.cs | 9 | ||||
-rw-r--r-- | src/cli/runtime/RT.cs | 7 | ||||
-rw-r--r-- | src/cli/runtime/Var.cs | 3 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/cli/runtime/Module.cs b/src/cli/runtime/Module.cs index e2c091fe..3e396783 100644 --- a/src/cli/runtime/Module.cs +++ b/src/cli/runtime/Module.cs @@ -52,7 +52,14 @@ static public Module findOrCreate(String name) return ns; } }
-
+
+public Var find(Symbol sym){
+ lock(vars)
+ {
+ return (Var) vars[sym];
+ }
+}
+
static public Var intern(String ns, String name)
{
return findOrCreate(ns).intern(Symbol.intern(name));
diff --git a/src/cli/runtime/RT.cs b/src/cli/runtime/RT.cs index bb0c3886..7a932f78 100644 --- a/src/cli/runtime/RT.cs +++ b/src/cli/runtime/RT.cs @@ -13,6 +13,7 @@ using System;
using System.Collections;
using System.IO;
+using System.Threading;
namespace clojure.lang
{
@@ -27,6 +28,12 @@ public class RT static public readonly Object[] chars;
+ static int id = 1;
+ static public int nextID()
+ {
+ return Interlocked.Increment(ref id);
+ }
+
static RT(){
chars = new Object[256];
for(int i=0;i<chars.Length;i++)
diff --git a/src/cli/runtime/Var.cs b/src/cli/runtime/Var.cs index 626c4f48..d2fae255 100644 --- a/src/cli/runtime/Var.cs +++ b/src/cli/runtime/Var.cs @@ -15,7 +15,8 @@ namespace clojure.lang {
public class Var : AFn
{
-public readonly Symbol name;
public Module module;
public Binding binding;
IPersistentMap threadBindings = PersistentArrayMap.EMPTY;
int tcount = 0;
internal Var(Symbol sym, Module ns)
{
if(sym.GetType() != typeof(Symbol))
throw new ArgumentException("Only simple symbols can be var names");
this.module = ns;
this.name = sym;
}
override public String ToString()
{
if(module == null)
return "#:" + name;
return module.name + ":" + name;
}
public Var bind(Object val)
{
lock(this){
if(binding == null)
+public readonly Symbol name;
public Module module;
public Binding binding;
+public bool hidden = false;
IPersistentMap threadBindings = PersistentArrayMap.EMPTY;
int tcount = 0;
internal Var(Symbol sym, Module ns)
{
if(sym.GetType() != typeof(Symbol))
throw new ArgumentException("Only simple symbols can be var names");
this.module = ns;
this.name = sym;
}
override public String ToString()
{
if(module == null)
return "#:" + name;
return module.name + ":" + name;
}
public Var bind(Object val)
{
lock(this){
if(binding == null)
binding = new Binding(val);
else
binding.val = val;
return this;
}
}
public Object getValue()
{
|