diff --git a/eval.c b/eval.c index 20947d69..0c9f6dce 100644 --- a/eval.c +++ b/eval.c @@ -12,8 +12,9 @@ static sexp analyze (sexp ctx, sexp x); static void generate (sexp ctx, sexp x); #if SEXP_USE_MODULES -static sexp sexp_load_module_file_op (sexp ctx sexp_api_params(self, n), sexp file, sexp env); -static sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file); +sexp sexp_load_module_file_op (sexp ctx sexp_api_params(self, n), sexp file, sexp env); +sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file); +sexp sexp_current_environment (sexp ctx sexp_api_params(self, n)); #endif sexp sexp_compile_error (sexp ctx, const char *message, sexp o) { @@ -1511,7 +1512,7 @@ sexp sexp_load_module_file (sexp ctx, const char *file, sexp env) { } #if SEXP_USE_MODULES -static sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file) { +sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file) { sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, file); return sexp_find_module_file(ctx, sexp_string_data(file)); } @@ -1520,6 +1521,9 @@ sexp sexp_load_module_file_op (sexp ctx sexp_api_params(self, n), sexp file, sex sexp_assert_type(ctx, sexp_envp, SEXP_ENV, env); return sexp_load_module_file(ctx, sexp_string_data(file), env); } +sexp sexp_current_environment (sexp ctx sexp_api_params(self, n)) { + return sexp_context_env(ctx); +} #endif sexp sexp_add_module_directory_op (sexp ctx sexp_api_params(self, n), sexp dir, sexp appendp) { diff --git a/lib/config.scm b/lib/config.scm index be6fb36a..ee35e1dd 100644 --- a/lib/config.scm +++ b/lib/config.scm @@ -1,5 +1,5 @@ ;; config.scm -- configuration module -;; Copyright (c) 2009 Alex Shinn. All rights reserved. +;; Copyright (c) 2009-2010 Alex Shinn. All rights reserved. ;; BSD-style license: http://synthcode.com/license.txt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -168,6 +168,7 @@ (define *modules* (list (cons '(scheme) (make-module #f (interaction-environment) '())) + (cons '(config) (make-module #f (current-environment) '())) (cons '(srfi 0) (make-module (list 'cond-expand) (interaction-environment) (list (list 'export 'cond-expand)))) diff --git a/opcodes.c b/opcodes.c index efc11d50..26622b55 100644 --- a/opcodes.c +++ b/opcodes.c @@ -163,6 +163,7 @@ _FN3(SEXP_STRING, SEXP_FIXNUM, "make-setter", 0, sexp_make_setter_op), #include "opt/plan9-opcodes.c" #endif #if SEXP_USE_MODULES +_FN0("current-environment", 0, sexp_current_environment), _FN1(SEXP_ENV, "env-exports", 0, sexp_env_exports_op), _FN1(SEXP_STRING, "find-module-file", 0, sexp_find_module_file_op), _FN2(SEXP_STRING, SEXP_ENV, "load-module-file", 0, sexp_load_module_file_op),