Login
7 branches 0 tags
Ben (Win10) Added closure metadata and moved the docstring over 005680e 3 years ago 634 Commits
nujel / stdlib / core / stacktrace.nuj
;; Nujel - Copyright (C) 2020-2021 - Benjamin Vincent Schulenburg
;; This project uses the MIT license, a copy should be included under /LICENSE

[defn describe/closure [c i]
  [when c
    [if [== c root-closure]
        [cat [ansi-blue [cat [int [or i 0]] "# <root environment>"]]
             "\r\n"]
        [do [def info [closure c]]
            [when info
              [def data [ref info :data]]
              [def l [length data]]
              [cat [ansi-blue [cat [int [or i 0]] "# " [str/write c]]]
                   " - "
                   [if [< l 16]
                       [str/write data]
                       "-+- Very big tree structure -+-"]
                   "\r\n"
                   [describe/closure [closure/caller c] [+ [int [or i 0]] 1]]]]]]]]

[defn stacktrace []
  [display [describe/closure [closure/caller [current-lambda]]]]]