diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jvm/clojure/lang/AFn.java | 23 | ||||
-rw-r--r-- | src/jvm/clojure/lang/AFunction.java | 47 | ||||
-rw-r--r-- | src/jvm/clojure/lang/Compiler.java | 4 | ||||
-rw-r--r-- | src/jvm/clojure/lang/RestFn.java | 2 |
4 files changed, 52 insertions, 24 deletions
diff --git a/src/jvm/clojure/lang/AFn.java b/src/jvm/clojure/lang/AFn.java index e09778da..bf406969 100644 --- a/src/jvm/clojure/lang/AFn.java +++ b/src/jvm/clojure/lang/AFn.java @@ -15,7 +15,7 @@ package clojure.lang; import java.util.Comparator; import java.io.Serializable; -public abstract class AFn extends Obj implements IFn, Comparator, Serializable{ +public abstract class AFn extends Obj implements IFn, Serializable{ public AFn(IPersistentMap meta){ super(meta); @@ -43,26 +43,7 @@ public void run(){ } } -public int compare(Object o1, Object o2){ - try - { - Object o = invoke(o1, o2); - - if(o instanceof Boolean) - { - if(RT.booleanCast(o)) - return -1; - return RT.booleanCast(invoke(o2,o1))? 1 : 0; - } - - Number n = (Number) o; - return n.intValue(); - } - catch(Exception e) - { - throw new RuntimeException(e); - } -} + public Object invoke() throws Exception{ return throwArity(); diff --git a/src/jvm/clojure/lang/AFunction.java b/src/jvm/clojure/lang/AFunction.java new file mode 100644 index 00000000..fed5e267 --- /dev/null +++ b/src/jvm/clojure/lang/AFunction.java @@ -0,0 +1,47 @@ +/** + * 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 Dec 16, 2008 */ + +package clojure.lang; + +import java.util.Comparator; + +public abstract class AFunction extends AFn implements Comparator, Fn{ + +public AFunction(IPersistentMap meta){ + super(meta); +} + +public AFunction(){ + super(); +} + +public int compare(Object o1, Object o2){ + try + { + Object o = invoke(o1, o2); + + if(o instanceof Boolean) + { + if(RT.booleanCast(o)) + return -1; + return RT.booleanCast(invoke(o2,o1))? 1 : 0; + } + + Number n = (Number) o; + return n.intValue(); + } + catch(Exception e) + { + throw new RuntimeException(e); + } +} +} diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index ae680438..765c4a9f 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -2864,7 +2864,7 @@ static public class FnExpr implements Expr{ Method.getMethod("clojure.lang.Var intern(clojure.lang.Symbol, clojure.lang.Symbol)"); final static Method afnctor = Method.getMethod("void <init>()"); final static Method restfnctor = Method.getMethod("void <init>(int)"); - final static Type aFnType = Type.getType(AFn.class); + final static Type aFnType = Type.getType(AFunction.class); final static Type restFnType = Type.getType(RestFn.class); final static Type DYNAMIC_CLASSLOADER_TYPE = Type.getType(DynamicClassLoader.class); @@ -2996,7 +2996,7 @@ static public class FnExpr implements Expr{ // ClassVisitor cv = new TraceClassVisitor(new CheckClassAdapter(cw), new PrintWriter(System.out)); //ClassVisitor cv = new TraceClassVisitor(cw, new PrintWriter(System.out)); cv.visit(V1_5, ACC_PUBLIC + ACC_SUPER, internalName, null, - isVariadic() ? "clojure/lang/RestFn" : "clojure/lang/AFn", new String[]{"clojure/lang/Fn"}); + isVariadic() ? "clojure/lang/RestFn" : "clojure/lang/AFunction", null); String source = (String) SOURCE.get(); int lineBefore = (Integer) LINE_BEFORE.get(); int lineAfter = (Integer) LINE_AFTER.get() + 1; diff --git a/src/jvm/clojure/lang/RestFn.java b/src/jvm/clojure/lang/RestFn.java index e770e336..f9ea3ed7 100644 --- a/src/jvm/clojure/lang/RestFn.java +++ b/src/jvm/clojure/lang/RestFn.java @@ -9,7 +9,7 @@ **/
package clojure.lang;
-public abstract class RestFn extends AFn{
+public abstract class RestFn extends AFunction{
protected int reqArity;
|