diff options
author | Rich Hickey <richhickey@gmail.com> | 2010-05-20 13:16:18 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2010-05-20 13:16:18 -0400 |
commit | 4f729ba2432d8ffbe7c2f74f680b472e528cba4c (patch) | |
tree | ec1fb22de4a9ebd4d5a71404c1020fc460d3e33e /src/jvm/clojure | |
parent | 46d004601d1f23aaec5cfe26c840632df1f2dd5a (diff) | |
parent | 4651e60808bb459355a3a5d0d649c4697c672e28 (diff) |
Merge branch 'patches'
Diffstat (limited to 'src/jvm/clojure')
-rw-r--r-- | src/jvm/clojure/lang/AFn.java | 48 | ||||
-rw-r--r-- | src/jvm/clojure/lang/Compiler.java | 23 | ||||
-rw-r--r-- | src/jvm/clojure/lang/RestFn.java | 46 |
3 files changed, 61 insertions, 56 deletions
diff --git a/src/jvm/clojure/lang/AFn.java b/src/jvm/clojure/lang/AFn.java index e6eafeba..a93cd7ed 100644 --- a/src/jvm/clojure/lang/AFn.java +++ b/src/jvm/clojure/lang/AFn.java @@ -32,110 +32,110 @@ public void run(){ public Object invoke() throws Exception{ - return throwArity(); + return throwArity(0); } public Object invoke(Object arg1) throws Exception{ - return throwArity(); + return throwArity(1); } public Object invoke(Object arg1, Object arg2) throws Exception{ - return throwArity(); + return throwArity(2); } public Object invoke(Object arg1, Object arg2, Object arg3) throws Exception{ - return throwArity(); + return throwArity(3); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) throws Exception{ - return throwArity(); + return throwArity(4); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) throws Exception{ - return throwArity(); + return throwArity(5); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) throws Exception{ - return throwArity(); + return throwArity(6); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) throws Exception{ - return throwArity(); + return throwArity(7); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) throws Exception{ - return throwArity(); + return throwArity(8); } public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9) throws Exception{ - return throwArity(); + return throwArity(9); } 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 throwArity(); + return throwArity(10); } 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 throwArity(); + return throwArity(11); } 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 throwArity(); + return throwArity(12); } 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 throwArity(); + return throwArity(13); } 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 throwArity(); + return throwArity(14); } 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 throwArity(); + return throwArity(15); } 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 throwArity(); + return throwArity(16); } 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 throwArity(); + return throwArity(17); } 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 throwArity(); + return throwArity(18); } 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 throwArity(); + return throwArity(19); } 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 throwArity(); + return throwArity(20); } @@ -144,7 +144,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20, Object... args) throws Exception{ - return throwArity(); + return throwArity(21); } public Object applyTo(ISeq arglist) throws Exception{ @@ -433,10 +433,10 @@ static public Object applyToHelper(IFn ifn, ISeq arglist) throws Exception{ } } -public Object throwArity(){ +public Object throwArity(int n){ String name = getClass().getSimpleName(); int suffix = name.lastIndexOf("__"); - throw new IllegalArgumentException("Wrong number of args passed to: " + throw new IllegalArgumentException("Wrong number of args (" + n + ") passed to: " + (suffix == -1 ? name : name.substring(0, suffix)).replace('_', '-')); } } diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index 6aceb282..8ce076d4 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -3078,9 +3078,11 @@ static public class FnExpr extends ObjExpr{ (munge(currentNS().name.name) + "$"); if(RT.second(form) instanceof Symbol) name = ((Symbol) RT.second(form)).name; - String simpleName = ((name != null ? - munge(name).replace(".", "_DOT_") : "fn") - + "__" + RT.nextID()); + String simpleName = name != null ? + (munge(name).replace(".", "_DOT_") + + (enclosingMethod != null ? "__" + RT.nextID() : "")) + : ("fn" + + "__" + RT.nextID()); fn.name = basename + simpleName; fn.internalName = fn.name.replace('.', '/'); fn.objtype = Type.getObjectType(fn.internalName); @@ -3898,9 +3900,9 @@ static public class ObjExpr implements Expr{ if(compiledClass == null) try { - if(RT.booleanCast(COMPILE_FILES.deref())) - compiledClass = RT.classForName(name);//loader.defineClass(name, bytecode); - else +// if(RT.booleanCast(COMPILE_FILES.deref())) +// compiledClass = RT.classForName(name);//loader.defineClass(name, bytecode); +// else { loader = (DynamicClassLoader) LOADER.deref(); compiledClass = loader.defineClass(name, bytecode, src); @@ -5338,7 +5340,8 @@ public static Object eval(Object form, boolean freshLoader) throws Exception{ && !(RT.first(form) instanceof Symbol && ((Symbol) RT.first(form)).name.startsWith("def"))) { - ObjExpr fexpr = (ObjExpr) analyze(C.EXPRESSION, RT.list(FN, PersistentVector.EMPTY, form), "eval"); + ObjExpr fexpr = (ObjExpr) analyze(C.EXPRESSION, RT.list(FN, PersistentVector.EMPTY, form), + "eval" + RT.nextID()); IFn fn = (IFn) fexpr.eval(); return fn.invoke(); } @@ -5829,7 +5832,9 @@ static void compile1(GeneratorAdapter gen, ObjExpr objx, Object form) throws Exc if(RT.meta(form) != null && RT.meta(form).containsKey(RT.LINE_KEY)) line = (Integer) RT.meta(form).valAt(RT.LINE_KEY); Var.pushThreadBindings( - RT.map(LINE, line)); + RT.map(LINE, line + ,LOADER, RT.makeClassLoader() + )); try { form = macroexpand(form); @@ -5879,7 +5884,7 @@ public static Object compile(Reader rdr, String sourcePath, String sourceName) t CONSTANT_IDS, new IdentityHashMap(), KEYWORDS, PersistentHashMap.EMPTY, VARS, PersistentHashMap.EMPTY - ,LOADER, RT.makeClassLoader() + // ,LOADER, RT.makeClassLoader() )); try diff --git a/src/jvm/clojure/lang/RestFn.java b/src/jvm/clojure/lang/RestFn.java index 192b5bfb..0724eec7 100644 --- a/src/jvm/clojure/lang/RestFn.java +++ b/src/jvm/clojure/lang/RestFn.java @@ -388,7 +388,7 @@ public Object applyTo(ISeq args) throws Exception{ , Util.ret1(args.next(),args=null));
}
- return throwArity();
+ return throwArity(-1);
}
public Object invoke() throws Exception{
@@ -397,7 +397,7 @@ public Object invoke() throws Exception{ case 0:
return doInvoke(null);
default:
- return throwArity();
+ return throwArity(0);
}
}
@@ -410,7 +410,7 @@ public Object invoke(Object arg1) throws Exception{ case 1:
return doInvoke(Util.ret1(arg1, arg1 = null), null);
default:
- return throwArity();
+ return throwArity(1);
}
}
@@ -425,7 +425,7 @@ public Object invoke(Object arg1, Object arg2) throws Exception{ case 2:
return doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), null);
default:
- return throwArity();
+ return throwArity(2);
}
}
@@ -446,7 +446,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3) throws Exception{ return doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),
null);
default:
- return throwArity();
+ return throwArity(3);
}
}
@@ -471,7 +471,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) throws return doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),
Util.ret1(arg4, arg4 = null), null);
default:
- return throwArity();
+ return throwArity(4);
}
}
@@ -501,7 +501,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),
Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null), null);
default:
- return throwArity();
+ return throwArity(5);
}
}
@@ -539,7 +539,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),
null);
default:
- return throwArity();
+ return throwArity(6);
}
}
@@ -565,7 +565,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object case 7:
return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, null);
default:
- return throwArity();
+ return throwArity(7);
}
}
@@ -593,7 +593,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object case 8:
return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, null);
default:
- return throwArity();
+ return throwArity(8);
}
}
@@ -623,7 +623,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object case 9:
return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, null);
default:
- return throwArity();
+ return throwArity(9);
}
}
@@ -655,7 +655,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object case 10:
return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, null);
default:
- return throwArity();
+ return throwArity(10);
}
}
@@ -689,7 +689,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object case 11:
return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, null);
default:
- return throwArity();
+ return throwArity(11);
}
}
@@ -725,7 +725,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object case 12:
return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, null);
default:
- return throwArity();
+ return throwArity(12);
}
}
@@ -777,7 +777,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object case 13:
return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, null);
default:
- return throwArity();
+ return throwArity(13);
}
}
@@ -833,7 +833,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
null);
default:
- return throwArity();
+ return throwArity(14);
}
}
@@ -892,7 +892,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15, null);
default:
- return throwArity();
+ return throwArity(15);
}
}
@@ -954,7 +954,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15, arg16, null);
default:
- return throwArity();
+ return throwArity(16);
}
}
@@ -1019,7 +1019,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15, arg16, arg17, null);
default:
- return throwArity();
+ return throwArity(17);
}
}
@@ -1088,7 +1088,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15, arg16, arg17, arg18, null);
default:
- return throwArity();
+ return throwArity(18);
}
}
@@ -1163,7 +1163,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15, arg16, arg17, arg18, arg19, null);
default:
- return throwArity();
+ return throwArity(19);
}
}
@@ -1246,7 +1246,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15, arg16, arg17, arg18, arg19, arg20, null);
default:
- return throwArity();
+ return throwArity(20);
}
}
@@ -1337,7 +1337,7 @@ public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
arg15, arg16, arg17, arg18, arg19, arg20, ArraySeq.create(args));
default:
- return throwArity();
+ return throwArity(21);
}
}
|