From f30e53265c7096209c84af92d07c7fc48b70926b Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 17 Apr 2012 00:06:11 +0900 Subject: [PATCH] adding (library x) support to cond-expand --- eval.c | 3 +++ include/chibi/eval.h | 1 + lib/init-7.scm | 1 + opcodes.c | 1 + 4 files changed, 6 insertions(+) diff --git a/eval.c b/eval.c index 19d3cc74..e6b6ea10 100644 --- a/eval.c +++ b/eval.c @@ -1866,6 +1866,9 @@ sexp sexp_load_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file, se sexp sexp_current_environment (sexp ctx, sexp self, sexp_sint_t n) { return sexp_context_env(ctx); } +sexp sexp_meta_environment (sexp ctx, sexp self, sexp_sint_t n) { + return sexp_global(ctx, SEXP_G_META_ENV); +} #endif sexp sexp_add_module_directory_op (sexp ctx, sexp self, sexp_sint_t n, sexp dir, sexp appendp) { diff --git a/include/chibi/eval.h b/include/chibi/eval.h index 2400dcd2..c643a1cf 100644 --- a/include/chibi/eval.h +++ b/include/chibi/eval.h @@ -70,6 +70,7 @@ SEXP_API sexp sexp_load_standard_env (sexp context, sexp env, sexp version); SEXP_API sexp sexp_find_module_file (sexp ctx, const char *file); SEXP_API sexp sexp_load_module_file (sexp ctx, const char *file, sexp env); SEXP_API sexp sexp_add_module_directory_op (sexp ctx, sexp self, sexp_sint_t n, sexp dir, sexp appendp); +SEXP_API sexp sexp_meta_environment (sexp ctx, sexp self, sexp_sint_t n); SEXP_API sexp sexp_extend_env (sexp ctx, sexp env, sexp vars, sexp value); SEXP_API sexp sexp_env_import_op (sexp ctx, sexp self, sexp_sint_t n, sexp to, sexp from, sexp ls, sexp immutp); SEXP_API sexp sexp_identifier_op(sexp ctx, sexp self, sexp_sint_t n, sexp x); diff --git a/lib/init-7.scm b/lib/init-7.scm index 89d97a46..a2cb2152 100644 --- a/lib/init-7.scm +++ b/lib/init-7.scm @@ -550,6 +550,7 @@ ((and) (every check (cdr x))) ((or) (any check (cdr x))) ((not) (not (check (cadr x)))) + ((library) (eval `(find-module ',(cadr x)) (%meta-env))) (else (error "cond-expand: bad feature" x))) (memq (identifier->symbol x) *features*))) (let expand ((ls (cdr expr))) diff --git a/opcodes.c b/opcodes.c index 42bf7aaa..62841a30 100644 --- a/opcodes.c +++ b/opcodes.c @@ -221,6 +221,7 @@ _OP(SEXP_OPC_SETTER, SEXP_OP_SLOTN_SET, 4, 0, SEXP_VOID, _I(SEXP_OBJECT), _I(SEX #endif #if SEXP_USE_MODULES _FN0(_I(SEXP_ENV), "current-environment", 0, sexp_current_environment), +_FN0(_I(SEXP_ENV), "%meta-env", 0, sexp_meta_environment), _FN1(SEXP_NULL, _I(SEXP_ENV), "env-exports", 0, sexp_env_exports_op), _FN1(_I(SEXP_STRING), _I(SEXP_STRING), "find-module-file", 0, sexp_find_module_file_op), _FN2(SEXP_VOID, _I(SEXP_STRING), _I(SEXP_ENV), "load-module-file", 0, sexp_load_module_file_op),