summaryrefslogtreecommitdiff
path: root/libguile/debug.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-03-29 17:15:25 -0700
committerAndy Wingo <wingo@pobox.com>2009-04-17 15:20:16 +0200
commit4e237f1460c06c8e13dd2db4a2c690342a532664 (patch)
tree8b7f4b321b03c2e476354978eb2ddb6e3e43b375 /libguile/debug.c
parente02e84deedacc2209e05b935742cb8268f5f0f9a (diff)
downloadguile-4e237f1460c06c8e13dd2db4a2c690342a532664.tar.gz
thread the module through syntax-case's expansion
* libguile/debug.h: * libguile/debug.c (scm_procedure_module): New procedure, returns the module that was current when the given procedure was defined. Used by syncase to scope free identifiers. * module/ice-9/psyntax-pp.scm: Recompiled. * module/ice-9/psyntax.scm: Thread the module through the syntax expansion. This is harder than it would appear because in many places the different components of syntax objects are destructured. * module/ice-9/syncase.scm (guile-macro): Adapt to new signature for syntax transformer functions.
Diffstat (limited to 'libguile/debug.c')
-rw-r--r--libguile/debug.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libguile/debug.c b/libguile/debug.c
index 20c8d4e6b..fe54b64df 100644
--- a/libguile/debug.c
+++ b/libguile/debug.c
@@ -400,6 +400,37 @@ SCM_DEFINE (scm_procedure_environment, "procedure-environment", 1, 0, 0,
}
#undef FUNC_NAME
+SCM_DEFINE (scm_procedure_module, "procedure-module", 1, 0, 0,
+ (SCM proc),
+ "Return the module that was current when this procedure was defined.\n"
+ "Free variables in this procedure are resolved relative to the\n"
+ "procedure's module.")
+#define FUNC_NAME s_scm_procedure_module
+{
+ SCM_VALIDATE_PROC (SCM_ARG1, proc);
+
+ if (scm_is_true (scm_program_p (proc)))
+ return scm_program_module (proc);
+ else
+ {
+ SCM env = scm_procedure_environment (proc);
+
+ if (scm_is_null (env))
+ return SCM_BOOL_F;
+ else
+ {
+ for (; !scm_is_null (scm_cdr (env)); env = scm_cdr (env))
+ ;
+ if (SCM_EVAL_CLOSURE_P (scm_car (env)))
+ return SCM_PACK (SCM_SMOB_DATA (scm_car (env)));
+ else
+ return SCM_BOOL_F;
+ }
+ }
+}
+#undef FUNC_NAME
+
+
/* Eval in a local environment. We would like to have the ability to