diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-08-30 15:02:43 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-08-30 15:02:43 +0000 |
commit | 66fa61d4f2353e626c1a026c135f9efd828f3c40 (patch) | |
tree | 48a9f3da90dfa7d87e2eac9ceaeaf92a45c21cc8 /src | |
parent | d48ddcdcd8edbbc6e40d4047f20e292f658f99b3 (diff) |
Fixed genclass method handling to max of 18 parameters
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/genclass.clj | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/src/clj/clojure/genclass.clj b/src/clj/clojure/genclass.clj index 3b958dee..f45f845a 100644 --- a/src/clj/clojure/genclass.clj +++ b/src/clj/clojure/genclass.clj @@ -75,6 +75,8 @@ the class as a resource from the classpath, e.g. in the example case, org/mydomain/MyClass.clj + Note that methods with a maximum of 18 parameters are supported. + Returns a map containing :name and :bytecode. Most uses will be satisfied by the higher-level gen-and-load-class and gen-and-store-class functions, which generate and immediately load, @@ -213,43 +215,46 @@ else-label (. gen (newLabel)) end-label (. gen (newLabel))] (. gen (visitCode)) - (when is-overload - (emit-get-var gen (overload-name mname pclasses)) - (. gen (dup)) - (. gen (ifNonNull found-label)) - (. gen (pop))) - (emit-get-var gen mname) - (. gen (dup)) - (. gen (ifNull else-label)) - (when is-overload - (. gen (mark found-label))) + (if (> (count pclasses) 18) + (else-gen gen m) + (do + (when is-overload + (emit-get-var gen (overload-name mname pclasses)) + (. gen (dup)) + (. gen (ifNonNull found-label)) + (. gen (pop))) + (emit-get-var gen mname) + (. gen (dup)) + (. gen (ifNull else-label)) + (when is-overload + (. gen (mark found-label))) ;if found - (when-not as-static - (. gen (loadThis))) + (when-not as-static + (. gen (loadThis))) ;box args - (dotimes i (count ptypes) - (. gen (loadArg i)) - (. clojure.lang.Compiler$HostExpr (emitBoxReturn nil gen (nth pclasses i)))) + (dotimes i (count ptypes) + (. gen (loadArg i)) + (. clojure.lang.Compiler$HostExpr (emitBoxReturn nil gen (nth pclasses i)))) ;call fn - (. gen (invokeInterface ifn-type (new Method "invoke" obj-type - (to-types (replicate (+ (count ptypes) - (if as-static 0 1)) - Object))))) - ;(into-array (cons obj-type - ; (replicate (count ptypes) obj-type)))))) + (. gen (invokeInterface ifn-type (new Method "invoke" obj-type + (to-types (replicate (+ (count ptypes) + (if as-static 0 1)) + Object))))) + ;(into-array (cons obj-type + ; (replicate (count ptypes) obj-type)))))) ;unbox return - (. gen (unbox rtype)) - (when (= (. rtype (getSort)) (. Type VOID)) - (. gen (pop))) - (. gen (goTo end-label)) - + (. gen (unbox rtype)) + (when (= (. rtype (getSort)) (. Type VOID)) + (. gen (pop))) + (. gen (goTo end-label)) + ;else call supplied alternative generator - (. gen (mark else-label)) - (. gen (pop)) - - (else-gen gen m) + (. gen (mark else-label)) + (. gen (pop)) + + (else-gen gen m) - (. gen (mark end-label)) + (. gen (mark end-label)))) (. gen (returnValue)) (. gen (endMethod)))) ] |