Previous: progutils pathanmes, Up: progutils [Index]
The following bindings are exported by the library (vicare
libraries)
.
Expand an R6RS program whose symbolic expression is sexp. Return 6 values:
A list of library
objects representing the libraries that need
to be invoked to run the code.
The fully expanded code from the body of the program.
A list of sublists representing the macros defined in the program.
A subst representing the top–level bindings.
A list representing the bindings exported by the program.
A list of symbols representing the options enabled for this program; iklib programs for details.
This function is for debugging purposes. Expand the program form
sexp and return the return values of
expand-top-level-program
in an alist with the following
symbols as keys:
invoke-lib* invoke-code visit-code export-subst global-env option*
We can toy with the program expander using the following code:
#!r6rs (import (vicare) (prefix (vicare programs) progs.)) (print-gensym #f) (print-graph #f) (debug-print (progs.expand-top-level-program->sexp ?sexp))
where ?sexp is the program symbolic expression. For example, expanding the program:
(import (vicare)) (define var 1) (define-syntax (mac stx) 2) (display var)
yields the invoke-code
:
(library-letrec* ((lex.var loc.lex.var '1) (lex.dummy loc.lex.dummy (begin (annotated-call (display var) (primitive display) lex.var) '#!void))) '#!void)
the visit-code
:
(set! loc.lab.mac (annotated-case-lambda (#'lambda #'stx #'2) ((lex.stx) '2)))
where the procedure is the result of compiling and evaluating the
expanded code; the export-subst
(with many entries removed):
((flmod . g2374) (flonum->string . g990) (flsquare . g743) ... (var . lab.var) (mac . lab.mac))
the global-env
:
((lab.var global . loc.lex.var) (lab.mac global-macro . loc.lab.mac))
Previous: progutils pathanmes, Up: progutils [Index]