diff options
author | Andy Wingo <wingo@pobox.com> | 2013-05-05 18:26:53 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-06-09 19:52:10 +0200 |
commit | e65f80af42aefe13fe870b92b912cfd0156a1ac1 (patch) | |
tree | 483f3286e99848cd89a995c085c598920604b8e9 /libguile/programs.c | |
parent | e2cbf527c48fba803ef0bada712c5514f45ec4e4 (diff) | |
download | guile-e65f80af42aefe13fe870b92b912cfd0156a1ac1.tar.gz |
RTL programs print with their name
* libguile/print.c (iprin1): Use scm_i_program_print for RTL programs
too.
* libguile/procprop.c (scm_procedure_name): For RTL programs, call
scm_i_rtl_program_name if there is no override.
* libguile/programs.h:
* libguile/programs.c (scm_i_rtl_program_name): New helper, dispatches
to (system vm program).
(scm_i_program_print): For RTL programs, the fallback prints the code
pointer too.
* module/system/vm/program.scm (rtl-program-name): Use the debug info to
get an RTL program name.
(write-program): Work with RTL programs too.
* test-suite/tests/rtl.test ("procedure name"): Add test.
Diffstat (limited to 'libguile/programs.c')
-rw-r--r-- | libguile/programs.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/libguile/programs.c b/libguile/programs.c index eb5972ab3..d3569159a 100644 --- a/libguile/programs.c +++ b/libguile/programs.c @@ -111,14 +111,16 @@ SCM_DEFINE (scm_rtl_program_code, "rtl-program-code", 1, 0, 0, } #undef FUNC_NAME -void -scm_i_rtl_program_print (SCM program, SCM port, scm_print_state *pstate) +SCM +scm_i_rtl_program_name (SCM program) { - scm_puts_unlocked ("#<rtl-program ", port); - scm_uintprint (SCM_UNPACK (program), 16, port); - scm_putc_unlocked (' ', port); - scm_uintprint ((scm_t_uintptr) SCM_RTL_PROGRAM_CODE (program), 16, port); - scm_putc_unlocked ('>', port); + static SCM rtl_program_name = SCM_BOOL_F; + + if (scm_is_false (rtl_program_name) && scm_module_system_booted_p) + rtl_program_name = + scm_c_private_variable ("system vm program", "rtl-program-name"); + + return scm_call_1 (scm_variable_ref (rtl_program_name), program); } void @@ -147,9 +149,20 @@ scm_i_program_print (SCM program, SCM port, scm_print_state *pstate) } else if (scm_is_false (write_program) || print_error) { - scm_puts_unlocked ("#<program ", port); - scm_uintprint (SCM_UNPACK (program), 16, port); - scm_putc_unlocked ('>', port); + if (SCM_RTL_PROGRAM_P (program)) + { + scm_puts_unlocked ("#<rtl-program ", port); + scm_uintprint (SCM_UNPACK (program), 16, port); + scm_putc_unlocked (' ', port); + scm_uintprint ((scm_t_uintptr) SCM_RTL_PROGRAM_CODE (program), 16, port); + scm_putc_unlocked ('>', port); + } + else + { + scm_puts_unlocked ("#<program ", port); + scm_uintprint (SCM_UNPACK (program), 16, port); + scm_putc_unlocked ('>', port); + } } else { |