 (defn compile-and-load
   ^Class [form]
   (debug "COMPILE-AND-LOAD: " form)
-  (binding [*top-level* true]
+  (binding [*top-level* 'eval]
     (let [[name bytecode] (compile form)]
       (.defineClass *class-loader* name bytecode form)
       (Class/forName name true *class-loader*))))

  (. gen pop))

(defn gen-applier
  [^ClassWriter cw {:keys [params restarg ^Type thistype] :as env}]
  (let [gen (GeneratorAdapter. Opcodes/ACC_PUBLIC (Method/getMethod "Object applyTo(Object)") nil nil cw)
        bad-arity (. gen newLabel)
        invoke-label (. gen newLabel)
        loop-start (. gen newLabel)
        list-local (. gen newLocal (asmtype wombat.datatypes.List))
        positional-args (repeat (count params) object-type)
        sig (into-array Type (if restarg
                               (conj (vec positional-args) (asmtype object-array-class))
                               positional-args))
        method (Method. "invoke" object-type sig)
        emit-list-cnt (fn []
                        (let [is-null (. gen newLabel)
                              end (. gen newLabel)]


(defn validate-rest-token!
  [params]
  (when-let [rest (seq (drop-while (complement special-token?) params))]
    (when (not= (count rest) 2)
      (throw (IllegalArgumentException. "invalid placement of #!rest token")))))

