diff options
author | Andy Wingo <wingo@pobox.com> | 2010-10-08 12:21:20 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-10-08 12:31:56 +0200 |
commit | b262b74b51142bbc066438fe034c7c22c000feb0 (patch) | |
tree | 6d9a22fe17fdaf29df3e73ef9bd97c9f211bbe6d /libguile/programs.c | |
parent | d608db1d593cf46af4a5fc519dcc7274d422378b (diff) | |
download | guile-b262b74b51142bbc066438fe034c7c22c000feb0.tar.gz |
add program-sources-pre-retire to core and define frame-next-source
* libguile/programs.h:
* libguile/programs.c (scm_program_source): Add an optional arg, the
sources table to traverse. Defaults to the result of
scm_program_sources.
* module/system/vm/program.scm (program-sources-pre-retire): Move
definition here from (system vm traps), and export.
* module/system/vm/traps.scm: Adapt.
* module/system/vm/frame.scm (frame-next-source): New exported binding,
returns the source line corresponding to the next instruction instead
of the previous instruction.
Diffstat (limited to 'libguile/programs.c')
-rw-r--r-- | libguile/programs.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/libguile/programs.c b/libguile/programs.c index 3a14f65ed..4404f832a 100644 --- a/libguile/programs.c +++ b/libguile/programs.c @@ -267,28 +267,37 @@ scm_i_program_properties (SCM program) } #undef FUNC_NAME -SCM_DEFINE (scm_program_source, "program-source", 2, 0, 0, - (SCM program, SCM ip), +static SCM +program_source (SCM program, size_t ip, SCM sources) +{ + SCM source = SCM_BOOL_F; + + while (!scm_is_null (sources) + && scm_to_size_t (scm_caar (sources)) <= ip) + { + source = scm_car (sources); + sources = scm_cdr (sources); + } + + return source; /* (addr . (filename . (line . column))) */ +} + +SCM_DEFINE (scm_program_source, "program-source", 2, 1, 0, + (SCM program, SCM ip, SCM sources), "") #define FUNC_NAME s_scm_program_source { SCM_VALIDATE_PROGRAM (1, program); - return scm_c_program_source (program, scm_to_size_t (ip)); + if (SCM_UNBNDP (sources)) + sources = scm_program_sources (program); + return program_source (program, scm_to_size_t (ip), sources); } #undef FUNC_NAME extern SCM scm_c_program_source (SCM program, size_t ip) { - SCM sources, source = SCM_BOOL_F; - - for (sources = scm_program_sources (program); - !scm_is_null (sources) - && scm_to_size_t (scm_caar (sources)) <= ip; - sources = scm_cdr (sources)) - source = scm_car (sources); - - return source; /* (addr . (filename . (line . column))) */ + return program_source (program, ip, scm_program_sources (program)); } SCM_DEFINE (scm_program_num_free_variables, "program-num-free-variables", 1, 0, 0, |