diff options
author | Rich Hickey <richhickey@gmail.com> | 2006-03-25 21:05:04 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2006-03-25 21:05:04 +0000 |
commit | d0aa19b1da4d796b3638c1dc8a43a314b9f62ff0 (patch) | |
tree | 19d222468321edb2fa4927a21ba1fb35d5fc8115 /src | |
parent | 894a0c81075b8f4b64b7f890ab0c8522a7a9986a (diff) |
added AMap
Diffstat (limited to 'src')
-rw-r--r-- | src/org/clojure/runtime/AMap.java | 35 | ||||
-rw-r--r-- | src/org/clojure/runtime/Cons.java | 2 | ||||
-rw-r--r-- | src/org/clojure/runtime/IFn.java | 34 | ||||
-rw-r--r-- | src/org/clojure/runtime/Symbol.java | 2 |
4 files changed, 71 insertions, 2 deletions
diff --git a/src/org/clojure/runtime/AMap.java b/src/org/clojure/runtime/AMap.java new file mode 100644 index 00000000..822bca6e --- /dev/null +++ b/src/org/clojure/runtime/AMap.java @@ -0,0 +1,35 @@ +/** + * 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 3:44:58 PM */ + +package org.clojure.runtime; + +import java.util.IdentityHashMap; + +public class AMap{ + +IdentityHashMap attrs; +public static final int INITIAL_SIZE = 7; + +public void put(Symbol key, Object val) + { + if(attrs == null) + attrs = new IdentityHashMap(INITIAL_SIZE); + attrs.put(key, val); + } + +public Object get(Symbol key) + { + if(attrs == null) + return null; + return attrs.get(key); + } +} diff --git a/src/org/clojure/runtime/Cons.java b/src/org/clojure/runtime/Cons.java index 7b6bbc32..22980e74 100644 --- a/src/org/clojure/runtime/Cons.java +++ b/src/org/clojure/runtime/Cons.java @@ -12,7 +12,7 @@ package org.clojure.runtime; -public class Cons{ +public class Cons extends AMap{ public Object first; public Cons rest; diff --git a/src/org/clojure/runtime/IFn.java b/src/org/clojure/runtime/IFn.java new file mode 100644 index 00000000..f5d1194f --- /dev/null +++ b/src/org/clojure/runtime/IFn.java @@ -0,0 +1,34 @@ +/** + * 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 3:54:03 PM */ + +package org.clojure.runtime; + +public interface IFn{ + +public Object invoke(ThreadLocalData tld) throws Exception; + +public Object invoke(ThreadLocalData tld, Object arg1) throws Exception; + +public Object invoke(ThreadLocalData tld, Object arg1, Object arg2) throws Exception; + +public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3) throws Exception; + +public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4) throws Exception; + +public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) + throws Exception; + +public Object invoke(ThreadLocalData tld, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, + Cons args) throws Exception; + +public Object applyTo(ThreadLocalData tld, Cons arglist) throws Exception; +} diff --git a/src/org/clojure/runtime/Symbol.java b/src/org/clojure/runtime/Symbol.java index f115963c..c5276982 100644 --- a/src/org/clojure/runtime/Symbol.java +++ b/src/org/clojure/runtime/Symbol.java @@ -12,5 +12,5 @@ package org.clojure.runtime; -public class Symbol{ +public class Symbol extends AMap{ } |