summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2007-07-05 17:17:25 +0000
committerRich Hickey <richhickey@gmail.com>2007-07-05 17:17:25 +0000
commitec855a884cc289812332d34a6b8f2ebf18ccb1cc (patch)
treed0decf5e2b9cbaf075eb1a3e72fa123448fab271 /src
parent296da9b329a1a7f07a8a8baeed2c59439e24e889 (diff)
interim checkin
Diffstat (limited to 'src')
-rw-r--r--src/jvm/clojure/lang/APersistentArray.java16
-rw-r--r--src/jvm/clojure/lang/Compiler.java24
-rw-r--r--src/jvm/clojure/lang/PersistentArray.java4
-rw-r--r--src/jvm/clojure/lang/PersistentArrayList.java6
-rw-r--r--src/jvm/clojure/lang/PersistentHashMap.java96
-rw-r--r--src/jvm/clojure/lang/PersistentHashtableMap.java6
-rw-r--r--src/jvm/clojure/lang/PersistentQueue.java22
-rw-r--r--src/jvm/clojure/lang/PersistentTreeMap.java2
-rw-r--r--src/jvm/clojure/lang/Var.java246
9 files changed, 102 insertions, 320 deletions
diff --git a/src/jvm/clojure/lang/APersistentArray.java b/src/jvm/clojure/lang/APersistentArray.java
index e479255a..9047296c 100644
--- a/src/jvm/clojure/lang/APersistentArray.java
+++ b/src/jvm/clojure/lang/APersistentArray.java
@@ -16,24 +16,10 @@ int _hash = -1;
public IPersistentCollection cons(Object o){
PersistentArrayList ret = new PersistentArrayList(this, this.count() + 10);
ret = ret.cons(o);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
-public Obj withMeta(IPersistentMap meta){
- if(_meta == meta)
- return this;
- try
- {
- Obj ret = (Obj) clone();
- ret._meta = meta;
- return ret;
- }
- catch(CloneNotSupportedException ignore)
- {
- return null;
- }
-}
public boolean equals(Object obj){
if(obj instanceof IPersistentArray)
diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java
index d6a384ad..a0e59906 100644
--- a/src/jvm/clojure/lang/Compiler.java
+++ b/src/jvm/clojure/lang/Compiler.java
@@ -167,8 +167,8 @@ static String compile(String ns, String className, LineNumberingPushbackReader..
}
for(ISeq vars = RT.seq(VARS.currentVal()); vars != null; vars = vars.rest())
{
- Var v = (Var) ((IMapEntry) vars.first()).val();
- format("static Var ~A;~%", munge(v.toString()));
+ TRef v = (TRef) ((IMapEntry) vars.first()).val();
+ format("static TRef ~A;~%", munge(v.toString()));
}
//todo declare static members for syms, quoted aggregates
@@ -191,8 +191,8 @@ static String compile(String ns, String className, LineNumberingPushbackReader..
}
for(ISeq vars = RT.seq(VARS.currentVal()); vars != null; vars = vars.rest())
{
- Var v = (Var) ((IMapEntry) vars.first()).val();
- format("~A = Module.intern(~S,~S);~%", munge(v.toString()), v.module.name, v.name.name);
+ TRef v = (TRef) ((IMapEntry) vars.first()).val();
+ //!format("~A = Module.intern(~S,~S);~%", munge(v.toString()), v.module.name, v.name.name);
}
//todo init syms and quoted aggregates
//emit the top level forms
@@ -1490,12 +1490,12 @@ private static Expr analyzeDef(C context, ISeq form) throws Exception{
throw new Exception("Too many arguments to def");
Symbol sym = (Symbol) RT.second(form);
Module module = (Module) _CRT_MODULE.currentVal();
- Var var = null;//!module.intern(baseSymbol(sym));
+ TRef var = null;//!module.intern(baseSymbol(sym));
registerVar(var);
VarExpr ve = new VarExpr(var, typeHint(sym));
Expr init = analyze(C.EXPRESSION, macroexpand(RT.third(form)));
- if(init instanceof FnExpr)
- ((FnExpr) init).name = "FN__" + munge(var.name.toString()) + "__" + RT.nextID();
+//! if(init instanceof FnExpr)
+// ((FnExpr) init).name = "FN__" + munge(var.name.toString()) + "__" + RT.nextID();
return new DefExpr(ve, init);
}
@@ -1542,14 +1542,14 @@ private static Expr analyzeSymbol(Symbol sym, boolean inFnPosition) throws Excep
b.valueTaken = true;
return new LocalBindingExpr(b, typeHint);
}
- Var v = lookupVar(sym);
+ TRef v = lookupVar(sym);
if(v != null)
return new VarExpr(v, typeHint);
throw new Exception("Unable to resolve symbol: " + sym.name + " in this context");
}
}
-static Var lookupVar(Symbol sym) throws Exception{
+static TRef lookupVar(Symbol sym) throws Exception{
Module module = (Module) _CRT_MODULE.currentVal();
// Var v = module.find(sym);
// if(v != null)
@@ -1576,7 +1576,7 @@ private static KeywordExpr registerKeyword(Keyword keyword) throws Exception{
return ke;
}
-private static void registerVar(Var var) throws Exception{
+private static void registerVar(TRef var) throws Exception{
IPersistentMap varsMap = (IPersistentMap) VARS.currentVal();
if(RT.get(var, varsMap) == null)
VARS.set(RT.assoc(var, var, varsMap));
@@ -1929,10 +1929,10 @@ static class LocalBindingExpr extends AnExpr{
}
static class VarExpr extends AnExpr{
- final Var var;
+ final TRef var;
final String typeHint;
- public VarExpr(Var var, String typeHint){
+ public VarExpr(TRef var, String typeHint){
this.var = var;
this.typeHint = typeHint;
}
diff --git a/src/jvm/clojure/lang/PersistentArray.java b/src/jvm/clojure/lang/PersistentArray.java
index dd85b12f..f6e6ace1 100644
--- a/src/jvm/clojure/lang/PersistentArray.java
+++ b/src/jvm/clojure/lang/PersistentArray.java
@@ -484,13 +484,13 @@ private PersistentArray getSetArray(){
protected PersistentArray create(Master master,int rev,int baseline, BitSet history){
PersistentArray ret = new PersistentArray(data.master, rev, baseline, history);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
protected PersistentArray create(int size, Object defaultVal, float loadFactor) {
PersistentArray ret = new PersistentArray(size, defaultVal, loadFactor);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
diff --git a/src/jvm/clojure/lang/PersistentArrayList.java b/src/jvm/clojure/lang/PersistentArrayList.java
index f3e62434..d4cda3a9 100644
--- a/src/jvm/clojure/lang/PersistentArrayList.java
+++ b/src/jvm/clojure/lang/PersistentArrayList.java
@@ -85,7 +85,7 @@ public PersistentArrayList pop() {
if(_count == 0)
throw new IllegalAccessError();
PersistentArrayList ret = new PersistentArrayList(data.master, data.rev, data.baseline, data.history, _count - 1);
- ret._meta = _meta;
+ //! ret._meta = _meta;
return ret;
}
@@ -106,13 +106,13 @@ private void grow() {
protected PersistentArray create(Master master,int rev,int baseline, BitSet history){
PersistentArray ret = new PersistentArrayList(data.master, rev, baseline, history,_count);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
protected PersistentArray create(int size, Object defaultVal, float loadFactor) {
PersistentArray ret = new PersistentArrayList(size, defaultVal, loadFactor,_count);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
diff --git a/src/jvm/clojure/lang/PersistentHashMap.java b/src/jvm/clojure/lang/PersistentHashMap.java
index d5f010a2..61cea6c9 100644
--- a/src/jvm/clojure/lang/PersistentHashMap.java
+++ b/src/jvm/clojure/lang/PersistentHashMap.java
@@ -42,7 +42,7 @@ public static IPersistentMap create(Object... init){
IPersistentMap ret = EMPTY;
for(int i = 0; i < init.length; i += 2)
{
- ret = ret.assoc(init[i],init[i + 1]);
+ ret = ret.assoc(init[i], init[i + 1]);
}
return ret;
}
@@ -50,14 +50,15 @@ public static IPersistentMap create(Object... init){
/**
* @param init {key1,val1,key2,val2,...}
*/
-public static IPersistentMap create(IPersistentMap meta,Object... init){
+public static IPersistentMap create(IPersistentMap meta, Object... init){
IPersistentMap ret = (IPersistentMap) EMPTY.withMeta(meta);
for(int i = 0; i < init.length; i += 2)
{
- ret = ret.assoc(init[i],init[i + 1]);
+ ret = ret.assoc(init[i], init[i + 1]);
}
return ret;
}
+
PersistentHashMap(int count, INode root){
this.count = count;
this.root = root;
@@ -83,7 +84,7 @@ public IPersistentMap assoc(Object key, Object val){
INode newroot = root.assoc(0, RT.hash(key), key, val, addedLeaf);
if(newroot == root)
return this;
- return new PersistentHashMap(meta(),addedLeaf.val == null ? count : count + 1, newroot);
+ return new PersistentHashMap(meta(), addedLeaf.val == null ? count : count + 1, newroot);
}
public Object valAt(Object key){
@@ -105,7 +106,7 @@ public IPersistentMap without(Object key){
return this;
if(newroot == null)
return (IPersistentMap) EMPTY.withMeta(meta());
- return new PersistentHashMap(meta(),count - 1, newroot);
+ return new PersistentHashMap(meta(), count - 1, newroot);
}
public Iterator iterator(){
@@ -120,6 +121,28 @@ public ISeq seq(){
return root.seq();
}
+static int mask(int hash, int shift){
+ //return ((hash << shift) >>> 27);// & 0x01f;
+ return (hash >>> shift) & 0x01f;
+}
+
+/*
+final static int[] pathmasks = new int[32];
+static{
+ pathmasks[0] = 0;
+ for(int i=1;i<32;i++)
+ pathmasks[i] = 0x80000000 >> (i - 1);
+}
+//final static int pathmask(int hash, int shift){
+// //return hash & (0x80000000 >> (shift - 1));
+// return hash & pathmasks[shift];
+// }
+
+static boolean diffPath(int shift, int hash1, int hash2){
+ return shift > 0 && ((hash1^hash2) & pathmasks[shift]) != 0;
+ //return shift > 0 && pathmask(hash1^hash2,shift) != 0;
+}
+*/
static interface INode{
INode assoc(int shift, int hash, Object key, Object val, Box addedLeaf);
@@ -128,11 +151,15 @@ static interface INode{
LeafNode find(int hash, Object key);
ISeq seq();
+
+ int getHash();
}
+/*
static interface ILeaf extends INode{
int getHash();
}
+*/
final static class EmptyNode implements INode{
@@ -153,15 +180,19 @@ final static class EmptyNode implements INode{
public ISeq seq(){
return null;
}
+
+ public int getHash(){
+ return 0;
+ }
}
final static class FullNode implements INode{
final INode[] nodes;
final int shift;
+ final int _hash;
+
+
- static int mask(int hash, int shift){
- return (hash >>> shift) & 0x01f;
- }
static int bitpos(int hash, int shift){
return 1 << mask(hash, shift);
@@ -170,9 +201,12 @@ final static class FullNode implements INode{
FullNode(INode[] nodes, int shift){
this.nodes = nodes;
this.shift = shift;
+ this._hash = nodes[0].getHash();
}
- public INode assoc(int shift, int hash, Object key, Object val, Box addedLeaf){
+ public INode assoc(int levelShift, int hash, Object key, Object val, Box addedLeaf){
+// if(levelShift < shift && diffPath(shift,hash,_hash))
+// return BitmapIndexedNode.create(levelShift, this, hash, key, val, addedLeaf);
int idx = mask(hash, shift);
INode n = nodes[idx].assoc(shift + 5, hash, key, val, addedLeaf);
@@ -187,7 +221,8 @@ final static class FullNode implements INode{
}
public INode without(int hash, Object key){
-
+// if(diffPath(shift,hash,_hash))
+// return this;
int idx = mask(hash, shift);
INode n = nodes[idx].without(hash, key);
if(n != nodes[idx])
@@ -207,6 +242,8 @@ final static class FullNode implements INode{
}
public LeafNode find(int hash, Object key){
+// if(diffPath(shift,hash,_hash))
+// return null;
return nodes[mask(hash, shift)].find(hash, key);
}
@@ -214,6 +251,10 @@ final static class FullNode implements INode{
return Seq.create(this, 0);
}
+ public int getHash(){
+ return _hash;
+ }
+
static class Seq extends ASeq{
final ISeq s;
final int i;
@@ -251,10 +292,7 @@ final static class BitmapIndexedNode implements INode{
final int bitmap;
final INode[] nodes;
final int shift;
-
- static int mask(int hash, int shift){
- return (hash >>> shift) & 0x01f;
- }
+ final int _hash;
static int bitpos(int hash, int shift){
return 1 << mask(hash, shift);
@@ -269,6 +307,7 @@ final static class BitmapIndexedNode implements INode{
this.bitmap = bitmap;
this.nodes = nodes;
this.shift = shift;
+ this._hash = nodes[0].getHash();
}
static INode create(int bitmap, INode[] nodes, int shift){
@@ -277,12 +316,19 @@ final static class BitmapIndexedNode implements INode{
return new BitmapIndexedNode(bitmap, nodes, shift);
}
- static INode create(int shift, ILeaf leaf, int hash, Object key, Object val, Box addedLeaf){
- return (new BitmapIndexedNode(bitpos(leaf.getHash(), shift), new INode[]{leaf}, shift))
+ static INode create(int shift, INode branch, int hash, Object key, Object val, Box addedLeaf){
+// int hx = branch.getHash()^hash;
+// while(mask(hx,shift) == 0)
+// shift += 5;
+// if(mask(branch.getHash(),shift) == mask(hash,shift))
+// return create(shift+5,branch,hash,key,val,addedLeaf);
+ return (new BitmapIndexedNode(bitpos(branch.getHash(), shift), new INode[]{branch}, shift))
.assoc(shift, hash, key, val, addedLeaf);
}
- public INode assoc(int shift, int hash, Object key, Object val, Box addedLeaf){
+ public INode assoc(int levelShift, int hash, Object key, Object val, Box addedLeaf){
+// if(levelShift < shift && diffPath(shift,hash,_hash))
+// return create(levelShift, this, hash, key, val, addedLeaf);
int bit = bitpos(hash, shift);
int idx = index(bit);
if((bitmap & bit) != 0)
@@ -308,6 +354,8 @@ final static class BitmapIndexedNode implements INode{
}
public INode without(int hash, Object key){
+// if(diffPath(shift,hash,_hash))
+// return this;
int bit = bitpos(hash, shift);
if((bitmap & bit) != 0)
{
@@ -319,6 +367,8 @@ final static class BitmapIndexedNode implements INode{
{
if(bitmap == bit)
return null;
+// if(nodes.length == 2)
+// return nodes[idx == 0?1:0];
INode[] newnodes = new INode[nodes.length - 1];
System.arraycopy(nodes, 0, newnodes, 0, idx);
System.arraycopy(nodes, idx + 1, newnodes, idx, nodes.length - (idx + 1));
@@ -333,6 +383,8 @@ final static class BitmapIndexedNode implements INode{
}
public LeafNode find(int hash, Object key){
+// if(diffPath(shift,hash,_hash))
+// return null;
int bit = bitpos(hash, shift);
if((bitmap & bit) != 0)
{
@@ -342,6 +394,10 @@ final static class BitmapIndexedNode implements INode{
return null;
}
+ public int getHash(){
+ return _hash;
+ }
+
public ISeq seq(){
return Seq.create(this, 0);
}
@@ -379,7 +435,7 @@ final static class BitmapIndexedNode implements INode{
}
-final static class LeafNode implements ILeaf, IMapEntry{
+final static class LeafNode implements INode, IMapEntry{
final int hash;
final Object key;
final Object val;
@@ -438,7 +494,7 @@ final static class LeafNode implements ILeaf, IMapEntry{
}
-final static class HashCollisionNode implements ILeaf{
+final static class HashCollisionNode implements INode{
final int hash;
final LeafNode[] leaves;
@@ -489,7 +545,7 @@ final static class HashCollisionNode implements ILeaf{
}
public ISeq seq(){
- return ArraySeq.create((Object[])leaves);
+ return ArraySeq.create((Object[]) leaves);
}
int findIndex(int hash, Object key){
diff --git a/src/jvm/clojure/lang/PersistentHashtableMap.java b/src/jvm/clojure/lang/PersistentHashtableMap.java
index 5f9c6a51..02c7265c 100644
--- a/src/jvm/clojure/lang/PersistentHashtableMap.java
+++ b/src/jvm/clojure/lang/PersistentHashtableMap.java
@@ -263,19 +263,19 @@ static int bucketFor(Object key, PersistentArray array){
IPersistentMap create(int capacity){
PersistentHashtableMap ret = new PersistentHashtableMap(capacity);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
IPersistentMap create(int count, PersistentArray array){
PersistentHashtableMap ret = new PersistentHashtableMap(count, array);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
IPersistentMap create(int i, PersistentArray newArray, int growAtCount){
PersistentHashtableMap ret = new PersistentHashtableMap(i, newArray, growAtCount);
- ret._meta = _meta;
+ //!ret._meta = _meta;
return ret;
}
diff --git a/src/jvm/clojure/lang/PersistentQueue.java b/src/jvm/clojure/lang/PersistentQueue.java
index 8f891ab6..93cd460d 100644
--- a/src/jvm/clojure/lang/PersistentQueue.java
+++ b/src/jvm/clojure/lang/PersistentQueue.java
@@ -34,7 +34,7 @@ int _hash = -1;
PersistentQueue(ISeq f, PersistentArrayList r, IPersistentMap meta) {
this.f = f;
this.r = r;
- this._meta = meta;
+ //!this._meta = meta;
}
public boolean equals(Object obj) {
@@ -79,7 +79,7 @@ public PersistentQueue pop() {
f1 = RT.seq(r);
r1 = null;
}
- return new PersistentQueue(f1, r1,_meta);
+ return new PersistentQueue(f1, r1,meta());
}
public int count() {
@@ -94,24 +94,10 @@ public ISeq seq() {
public PersistentQueue cons(Object o) {
if(f == null) //empty
- return new PersistentQueue(RT.list(o), null,_meta);
+ return new PersistentQueue(RT.list(o), null,meta());
else
return new PersistentQueue(f,
- (PersistentArrayList) (r != null ? r : new PersistentArrayList(INITIAL_REAR_SIZE)).cons(o),_meta);
-}
-
-public Obj withMeta(IPersistentMap meta) {
- if(_meta == meta)
- return this;
- try{
- Obj ret = (Obj) clone();
- ret._meta = meta;
- return ret;
- }
- catch(CloneNotSupportedException ignore)
- {
- return null;
- }
+ (PersistentArrayList) (r != null ? r : new PersistentArrayList(INITIAL_REAR_SIZE)).cons(o),meta());
}
static class Seq extends ASeq {
diff --git a/src/jvm/clojure/lang/PersistentTreeMap.java b/src/jvm/clojure/lang/PersistentTreeMap.java
index ed46e515..5f4104df 100644
--- a/src/jvm/clojure/lang/PersistentTreeMap.java
+++ b/src/jvm/clojure/lang/PersistentTreeMap.java
@@ -787,7 +787,7 @@ static public void main(String args[]){
{
IMapEntry o = (IMapEntry) it.next();
if(!set.contains(o.key()))
- System.err.println("Can't find: " + o);
+ System.err.println("Can't find: " + o.key());
//else if(n < 2000)
// System.out.print(o.key().toString() + ",");
}
diff --git a/src/jvm/clojure/lang/Var.java b/src/jvm/clojure/lang/Var.java
deleted file mode 100644
index 19cdb716..00000000
--- a/src/jvm/clojure/lang/Var.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/**
- * 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 Apr 19, 2006 */
-
-package clojure.lang;
-
-import java.util.Random;
-
-public class Var extends AFn{
-
-public final Symbol name;
-public Module module;
-public final TRef binding;
-public boolean exported = false;
-
-Var(Symbol sym, Module ns){
- if(!(sym.getClass() == Symbol.class))
- throw new IllegalArgumentException("Only simple symbols can be var names");
- this.module = ns;
- this.name = sym;
- this.binding = new TRef();
-}
-
-public String toString(){
- if(module == null)
- return "#:" + name;
- return module.name + ":" + name;
-}
-
-public Var bind(Object val) throws Exception{
- //must be called in transaction
- binding.set(val);
-
- return this;
-}
-
-public Object getValue() throws Exception{
- if(binding.isBound())
- return binding.val();
- throw new IllegalStateException(this.toString() + " is unbound.");
-}
-
-public Object setValue(Object val) throws Exception{
- //must be called in transaction
- return binding.set(val);
-}
-
-void pushThreadBinding(Object val){
-
-}
-
-public void popThreadBinding(){
-
-}
-
-
-final public IFn fn(){
- if(binding.isBound())
- return (IFn) binding.currentVal();
- throw new IllegalStateException(this.toString() + " is unbound.");
-}
-
-public Object invoke() throws Exception{
- return fn().invoke();
-}
-
-public Object invoke(Object arg1) throws Exception{
- return fn().invoke(arg1);
-}
-
-public Object invoke(Object arg1, Object arg2) throws Exception{
- return fn().invoke(arg1, arg2);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3) throws Exception{
- return fn().invoke(arg1, arg2, arg3);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)
- throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)
- throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,
- arg16);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,
- arg16, arg17);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,
- arg16, arg17, arg18);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,
- arg16, arg17, arg18, arg19);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)
- throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,
- arg16, arg17, arg18, arg19, arg20);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,
- Object... args)
- throws Exception{
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,
- arg16, arg17, arg18, arg19, arg20, args);
-}
-
-
-static volatile Integer o = 1;
-
-public static void main(String[] args){
-
- try
- {
- int n = Integer.parseInt(args[0]);
- class Test extends AFn{
- int x = 0;
-
- public Object invoke(Object arg1) throws Exception{
- x += o.intValue();
- return this;
- }
-
- public String toString(){
- return Integer.toString(x);
- }
-
- }
-
- Var test = Module.intern("test", "test");
-
- test.bind(new Test());
-
- Random rand;
-
- Object result = 0;
-
- rand = new Random(42);
- long startTime = System.nanoTime();
-
- for(int i = 0; i < n; i++)
- result = test.invoke(result);
- long estimatedTime = System.nanoTime() - startTime;
- System.out.println("val:" + result + ", time: " + estimatedTime / 1000000);
-
- rand = new Random(42);
- startTime = System.nanoTime();
-
- for(int i = 0; i < n; i++)
- result = ((IFn) test.getValue()).invoke(result);
- estimatedTime = System.nanoTime() - startTime;
- System.out.println("val:" + result + ", time: " + estimatedTime / 1000000);
-
- }
-
- catch(Exception e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-
-}
-}