diff options
author | Andy Wingo <wingo@pobox.com> | 2013-05-01 22:19:04 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-05-17 22:24:02 +0200 |
commit | 8a3e07c371538eefd066bb6d6d884a1d50782e0c (patch) | |
tree | 8d8cc54156a1bf8347c8218e5cf33761eac8ab37 | |
parent | fd899af33d84a1263f68c066c2bbb612cdba9606 (diff) | |
download | guile-8a3e07c371538eefd066bb6d6d884a1d50782e0c.tar.gz |
add rtl program predicate and accessor to programs.c
* libguile/programs.c (scm_rtl_program_code): New procedure.
(scm_rtl_program_p): New procedure.
* module/system/vm/program.scm: Export the new functions.
-rw-r--r-- | libguile/programs.c | 23 | ||||
-rw-r--r-- | libguile/programs.h | 5 | ||||
-rw-r--r-- | module/system/vm/program.scm | 1 |
3 files changed, 27 insertions, 2 deletions
diff --git a/libguile/programs.c b/libguile/programs.c index 971ea9d0a..eb5972ab3 100644 --- a/libguile/programs.c +++ b/libguile/programs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -99,6 +99,18 @@ SCM_DEFINE (scm_make_rtl_program, "make-rtl-program", 1, 2, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_rtl_program_code, "rtl-program-code", 1, 0, 0, + (SCM program), + "") +#define FUNC_NAME s_scm_rtl_program_code +{ + SCM_VALIDATE_RTL_PROGRAM (1, program); + + /* FIXME: we need scm_from_uintptr (). */ + return scm_from_size_t ((size_t) SCM_RTL_PROGRAM_CODE (program)); +} +#undef FUNC_NAME + void scm_i_rtl_program_print (SCM program, SCM port, scm_print_state *pstate) { @@ -161,6 +173,15 @@ SCM_DEFINE (scm_program_p, "program?", 1, 0, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_rtl_program_p, "rtl-program?", 1, 0, 0, + (SCM obj), + "") +#define FUNC_NAME s_scm_rtl_program_p +{ + return scm_from_bool (SCM_RTL_PROGRAM_P (obj)); +} +#undef FUNC_NAME + SCM_DEFINE (scm_program_base, "program-base", 1, 0, 0, (SCM program), "") diff --git a/libguile/programs.h b/libguile/programs.h index f2d519c9c..732594cd2 100644 --- a/libguile/programs.h +++ b/libguile/programs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -32,6 +32,7 @@ #define SCM_RTL_PROGRAM_FREE_VARIABLE_REF(x,i) (SCM_RTL_PROGRAM_FREE_VARIABLES (x)[i]) #define SCM_RTL_PROGRAM_FREE_VARIABLE_SET(x,i,v) (SCM_RTL_PROGRAM_FREE_VARIABLES (x)[i]=(v)) #define SCM_RTL_PROGRAM_NUM_FREE_VARIABLES(x) (SCM_CELL_WORD_0 (x) >> 16) +#define SCM_VALIDATE_RTL_PROGRAM(p,x) SCM_MAKE_VALIDATE (p, x, RTL_PROGRAM_P) static inline SCM scm_i_make_rtl_program (const scm_t_uint32 *code) @@ -40,6 +41,8 @@ scm_i_make_rtl_program (const scm_t_uint32 *code) } SCM_INTERNAL SCM scm_make_rtl_program (SCM bytevector, SCM byte_offset, SCM free_variables); +SCM_INTERNAL SCM scm_rtl_program_p (SCM obj); +SCM_INTERNAL SCM scm_rtl_program_code (SCM program); SCM_INTERNAL void scm_i_rtl_program_print (SCM program, SCM port, scm_print_state *pstate); diff --git a/module/system/vm/program.scm b/module/system/vm/program.scm index 47dc927d2..187509313 100644 --- a/module/system/vm/program.scm +++ b/module/system/vm/program.scm @@ -44,6 +44,7 @@ program-meta program-objcode program? program-objects + rtl-program? rtl-program-code program-module program-base program-free-variables program-num-free-variables |