helpers.lisp 552 B

1234567891011121314151617181920212223242526
  1. (import compiler/nodes compiler)
  2. (import compiler/resolve compiler)
  3. (import core/prelude ())
  4. (defmacro exported-vars ()
  5. "Generate a struct with all variables exported in the current module.
  6. ### Example:
  7. ```cl
  8. > (let [(a 1)]
  9. . (exported-vars))
  10. out = {\"a\" 1}
  11. ```
  12. ```cl :no-test
  13. (define x 1)
  14. (define y 2)
  15. (define z 3)
  16. (exported-vars) ;; { :x 1 :y 2 :z 3 }
  17. ```"
  18. (with (out '{})
  19. (for-pairs (name var) (compiler/scope-exported)
  20. (push! out name)
  21. (push! out (compiler/var->symbol var)))
  22. out))