mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 22:29:16 +02:00
making (config) an importable module
self-reference handled with new current-environment
This commit is contained in:
parent
5308e5b45b
commit
d43cf9f6c2
3 changed files with 10 additions and 4 deletions
10
eval.c
10
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) {
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Reference in a new issue