   (. gen swap)
   (. gen invokeVirtual (asmtype java.io.PrintWriter) (Method/getMethod "void println(String)")))
 
-;; (def invoke-handle
-;;   (Handle. Opcodes/H_INVOKESTATIC
-;;            "wombat/Global"
-;;            "bootstrapInvoke"
-;;            (.toMethodDescriptorString
-;;             (MethodType/methodType CallSite
-;;                                    (into-array Class [MethodHandles$Lookup String MethodType String])))))
-
 (defmethod emit-seq -invoke-
   [env context gen [fun & args :as call]]
   (when (nil? fun)

    (catch ClassNotFoundException e)))

(def object-array-class (class (object-array 0)))

;; (dotimes [n 21]
;;   (eval `(gen-interface :name ~(symbol (str "wombat.ILambda" n))
;;                         :extends [~'wombat.ILambda]
;;                         :methods [[~'invoke [~@(repeat n Object)] ~'Object]]))
;;   (eval `(import ~(symbol (str "wombat.ILambda" n)))))

;; (eval
;;  `(gen-interface :name ~'wombat.ILambda21
;;                  :extends [~'wombat.ILambda]
;;                  :methods [[~'invoke [~@(repeat 20 Object) ~(.getName object-array-class)] ~'Object]]))

(def ^:dynamic *print-debug* true)
(defn debug [& vals]

  (debug "emitting invoke:" call)
  (debug "context:" context)

  (emit env :context/expression gen fun)

  (. gen dup)
  (. gen checkCast ilambda-type)
  (AsmUtil/pushInt gen (count args))
