anchor.diff:  
       stats))
   
  +(defun build-stack (parent stack i)
  +  ;; Increment the number of times hit
  +  (.<! parent :n (+ (.> parent :n) 1))
  +
  +  (when (<= i (# stack))
  +    (let* [(elem (nth stack i))
  +           (hash (.. (.> first :source) "|" (.> first :linedefined)))
  +           (child (.> parent hash))]
  +      (unless child
  +        (set! child elem)
  +        (.<! first :n 0)
  +        (.<! parent hash child))
  +
  +      (build-stack child stack (+ i 1)))))
  +
  +(defun profile-stack (fn mappings)
  +  :hidden
  +  (with (stacks '())
  +
  +    (debug/sethook
  +      (lambda (action)
  +        (let* [(pos 2)
  +               (stack '())
  +               (info (debug/getinfo pos "Sn"))
  +          (while info
  +            (push-cdr! stack info)
  +            (inc! pos)
  +            (set! info (debug/getinfo pos "Sn")))
  +          (push-cdr! stacks stack)))
  +
  +      "", 1e5)
  +
  +    (fn)
  +
  +    (debug/sethook)
  +
  +
  +    (with (folded (const-struct :n 0))
  +      (for-each stack stacks
  +        (built-stack folded stack 1)))))
  +
  +
   (defun run-lua (compiler args)
  +  :hidden
     (when (nil? (.> args :input))
       (logger/put-error! (.> compiler :log) "No inputs to run.")
       (exit! 1))
  
positive.code: (import urn/logger logger)
  (import urn/traceback traceback)
  
  (defun run-with-profiler (fn mappings)
    (let* [(stats (empty-struct))
           (call-stack '())]
  
  
negative.code:                         (logger/put-error! logger "Execution failed.")
                          (print! (traceback/remap-traceback (struct name lines) msg))
                          (exit! 1)])))
           (case (string/lower (.> args :profile))
             ["none"  (exec)]
             ["call"  (profile-call exec (struct name lines))]
             ["stack" (profile-stack exec (struct name lines))]
             [?x
              (logger/put-error! logger (.. "Unknown profiler '" x "'"))
              (exit! 1)]))])))
  
  (define task
    (struct
  