mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
core: fix Debug.trace for new evaluator
This commit is contained in:
parent
ed4c4431dc
commit
1b39139d7b
@ -38,9 +38,19 @@ immediately, raising a `SIGABRT` if it fails.")
|
||||
|
||||
(doc trace "prints the value of an expression to `stdout`, then returns its value.")
|
||||
(defmacro trace [x]
|
||||
(list 'let-do (array 'tmp x)
|
||||
(list 'IO.println (list 'ref (list 'fmt "%s:%d:%d: %s" (file x) (line x) (column x) '&(str tmp))))
|
||||
'tmp)
|
||||
(let [sym (gensym)]
|
||||
(list 'let-do [sym x]
|
||||
; we use eval here to ensure we resolve the symbol before putting it
|
||||
; into file, line, and column
|
||||
(list 'IO.println
|
||||
(list 'ref
|
||||
(list 'fmt "%s:%d:%d: %s"
|
||||
(eval (list 'file x))
|
||||
(eval (list 'line x))
|
||||
(eval (list 'column x))
|
||||
(list 'ref (list 'str sym)))))
|
||||
sym)
|
||||
)
|
||||
)
|
||||
|
||||
(doc leak-array "leaks some memory. This function is useful for testing tools that detect leaks.")
|
||||
|
Loading…
Reference in New Issue
Block a user