   (:require [clojure.java.io]
             [clojure.string :as string]
             [spyscope.core :as spy]))
+
+(def ^:dynamic locals (atom []))
 
 (def macros
   {'up    [[:ldc 0 "; up"]]

  {:pre [(list? code)]
   :post [(vector? (:code %))
          (every? vector? (:code %))]}
  (let [fns (conj fns {:name name})
        code (->> body
                  (mapcat #(compile-form args fns %))
                  (tag-with name))
        code (concat code [[:rtn]])]
    {:name name
     :code (vec code)
     :length (count code)}))

(defn compile-ai
  [file]

      (= (first form) 'quote)
      (concat (mapcat #(compile-form vars fns %) (second form))
              (repeat (dec (count form)) [:cons]))

      ;; Variable declaration
      (= (first form) 'def)
      (let [[_ var-name val] form]
        (if (neg? (.indexOf @locals var-name))
          (swap! locals conj var-name))
        (concat
         (compile-form vars fns val)
         [[:st 0 (.indexOf @locals var-name) (format "; store %s" var-name)]]))

      ;; function call
      :else
