 (defn stack-line->canonical-frame
   "Parses a stack line into a frame representation, returning nil
   if parse failed."
-  [stack-line]
+  [stack-line opts]
   (let [[function file line column]
         (rest (re-matches #"(.*)@file://(.*):([0-9]+):([0-9]+)"
                 stack-line))]
     (if (and file function line column)
-      {:file     file
+      {:file     (string/replace
+                   (.getCanonicalFile (io/file file))
+                   (str (System/getProperty "user.dir") File/separator
+                     (util/output-directory opts) File/separator)
+                   "")
        :function function
        :line     (Long/parseLong line)
        :column   (Long/parseLong column)})))

  "Parse a raw JSC stack representation, parsing it into stack frames.
  The canonical stacktrace must be a vector of maps of the form
  {:file <string> :function <string> :line <integer> :column <integer>}."
  [raw-stacktrace]
  (->> raw-stacktrace
    string/split-lines
    (map stack-line->canonical-frame)
    (remove nil?)
    vec))


            {:status (keyword (:status result))
             :value  (:value result)}
            (when-let [raw-stacktrace (:stacktrace result)]
              {:stacktrace raw-stacktrace})))))))

(defn load-javascript
  "Load a Closure JavaScript file into the JSC REPL process."
