core: Rename the 'current-module' symbol.

This change renames 'current-module' to 'current-environment'.  This
will make way for 'current-module' to actually be a module.

* include/mes/symbols.h (cell_symbol_current_module): Rename this...
(cell_symbol_current_environment): ...to this.
* src/eval-apply.c: Adjust accordingly.
* src/symbol.c: Adjust accordingly, and update the Scheme name to
'current-environment'.
* mes/module/mes/base.mes: Adjust accordingly.
* mes/module/mes/boot-0.scm: Adjust accordingly.
* mes/module/mes/boot-00.scm: Adjust accordingly.
* mes/module/mes/boot-01.scm: Adjust accordingly.
* mes/module/mes/boot-02.scm: Adjust accordingly.
* mes/module/mes/boot-03.scm: Adjust accordingly.
* mes/module/mes/display.mes: Adjust accordingly.
* mes/module/mes/module.mes: Adjust accordingly.
* mes/module/mes/psyntax-0.mes: Adjust accordingly.
* mes/module/mes/repl.mes: Adjust accordingly.
* mes/module/mes/scm.mes: Adjust accordingly.
* mes/module/srfi/srfi-16.scm: Adjust accordingly.
* mes/module/srfi/srfi-26.scm: Adjust accordingly.
* module/mescc/compile.scm: Adjust accordingly.
* scaffold/boot/17-open-input-string.scm: Adjust accordingly.
* scaffold/boot/4c-quasiquote.scm: Adjust accordingly.
* scaffold/boot/4f-string-split.scm: Adjust accordingly.
* scaffold/boot/50-make-string.scm: Adjust accordingly.
* scaffold/boot/50-string-join.scm: Adjust accordingly.
* scaffold/boot/51-module.scm: Adjust accordingly.
* scaffold/boot/52-define-module.scm: Adjust accordingly.
* scaffold/boot/60-let-syntax-expanded.scm: Adjust accordingly.
* scaffold/boot/60-let-syntax.scm: Adjust accordingly.
* scaffold/gc.scm: Adjust accordingly.
* tests/gc.test: Adjust accordingly.
* tests/psyntax.test: Adjust accordingly.
This commit is contained in:
Timothy Sample 2022-03-30 10:47:46 -06:00
parent e743c1386c
commit a8ce580123
29 changed files with 61 additions and 61 deletions

View File

@ -86,7 +86,7 @@ extern struct scm *cell_symbol_portable_macro_expand;
extern struct scm *cell_symbol_sc_expander_alist;
extern struct scm *cell_symbol_call_with_values;
extern struct scm *cell_symbol_call_with_current_continuation;
extern struct scm *cell_symbol_current_module;
extern struct scm *cell_symbol_current_environment;
extern struct scm *cell_symbol_primitive_load;
extern struct scm *cell_symbol_car;
extern struct scm *cell_symbol_cdr;

View File

@ -72,7 +72,7 @@
(define call/cc call-with-current-continuation)
(define (command-line) %argv)
(define (read) (read-env (current-module)))
(define (read) (read-env (current-environment)))
(define-macro (and . x)
(if (null? x) #t

View File

@ -30,7 +30,7 @@
(define mes %version)
(define (defined? x)
(module-variable (current-module) x))
(module-variable (current-environment) x))
(define (cond-expand-expander clauses)
(if (defined? (car (car clauses)))
@ -67,10 +67,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)
@ -101,7 +101,7 @@
;; boot-03.scm
(define guile? #f)
(define mes? #t)
(define (primitive-eval e) (core:eval e (current-module)))
(define (primitive-eval e) (core:eval e (current-environment)))
(define eval core:eval)
(define (port-filename port) "<stdin>")
@ -112,10 +112,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define-macro (load file)
@ -137,7 +137,7 @@
(append2 (car rest) (apply append (cdr rest))))))
(if (not (defined? '%datadir))
(module-define! (current-module) '%datadir "mes"))
(module-define! (current-environment) '%datadir "mes"))
(define %moduledir (string-append %datadir "/module/"))
@ -270,7 +270,7 @@ General help using GNU software: <http://gnu.org/gethelp/>
(setenv "GUILE_LOAD_PATH" (string-append dir ":" (getenv "GUILE_LOAD_PATH")))))
(when command
(let* ((prev (set-current-input-port (open-input-string command)))
(expr (cons 'begin (read-input-file-env (current-module))))
(expr (cons 'begin (read-input-file-env (current-environment))))
(set-current-input-port prev))
(primitive-eval expr)
(exit 0)))

View File

@ -20,7 +20,7 @@
(define mes %version)
(define (defined? x)
(module-variable (current-module) x))
(module-variable (current-environment) x))
(define (cond-expand-expander clauses)
(if (defined? (car (car clauses)))

View File

@ -20,7 +20,7 @@
(define mes %version)
(define (defined? x)
(module-variable (current-module) x))
(module-variable (current-environment) x))
(define (cond-expand-expander clauses)
(if (defined? (car (car clauses)))
@ -55,10 +55,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -30,7 +30,7 @@
(define mes %version)
(define (defined? x)
(module-variable (current-module) x))
(module-variable (current-environment) x))
(define (cond-expand-expander clauses)
(if (defined? (car (car clauses)))
@ -67,10 +67,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -30,7 +30,7 @@
(define mes %version)
(define (defined? x)
(module-variable (current-module) x))
(module-variable (current-environment) x))
(define (cond-expand-expander clauses)
(if (defined? (car (car clauses)))
@ -67,10 +67,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)
@ -101,7 +101,7 @@
;; boot-03.scm
(define guile? #f)
(define mes? #t)
(define (primitive-eval e) (core:eval e (current-module)))
(define (primitive-eval e) (core:eval e (current-environment)))
(define eval core:eval)
(define (port-filename port) "<stdin>")
@ -112,10 +112,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define-macro (load file)

View File

@ -104,7 +104,7 @@
(write-char x port)))))
((closure? x)
(display "#<procedure " port)
(let ((name (and=> (next-xassq2 x (current-module)) car)))
(let ((name (and=> (next-xassq2 x (current-environment)) car)))
(display name port))
(display " " port)
(display (cadr (core:cdr x)) port)

View File

@ -53,7 +53,7 @@
(push! *input-ports* (current-input-port))
(set-current-input-port (open-input-file (string-append %moduledir (module->file module))))
(let ((x (core:eval (append2 (cons 'begin (read-input-file-env a))
'((current-module)))
'((current-environment)))
a)))
(set-current-input-port (pop! *input-ports*))
x))

View File

@ -18,11 +18,11 @@
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(define (interaction-environment) (current-module))
(define (interaction-environment) (current-environment))
(define (eval x . environment)
(core:eval (if (and (pair? x) (equal? (car x) "noexpand")) (cadr x) x)
(if (null? environment) (current-module) (car environment))))
(if (null? environment) (current-environment) (car environment))))
(define annotation? (lambda (x) #f))
(define (self-evaluating? x)

View File

@ -150,7 +150,7 @@ along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(lambda () #f)))))
(display welcome)
(let loop ((a (current-module)))
(let loop ((a (current-environment)))
(display "mes> ")
(force-output)
(catch #t

View File

@ -87,9 +87,9 @@
(define integer? number?)
(define (read . port)
(if (null? port) (read-env (current-module))
(if (null? port) (read-env (current-environment))
(let* ((prev (set-current-input-port (car port)))
(result (read-env (current-module))))
(result (read-env (current-environment))))
result)))
(if (not (defined? 'peek-char))

View File

@ -51,7 +51,7 @@
(define-module (srfi srfi-16)
:export-syntax (case-lambda))
(cond-expand-provide (current-module) '(srfi-16))
(cond-expand-provide (current-environment) '(srfi-16))
(define-macro (case-lambda . clauses)

View File

@ -22,7 +22,7 @@
(define-module (srfi srfi-26)
:export (cut cute))
(cond-expand-provide (current-module) '(srfi-26))
(cond-expand-provide (current-environment) '(srfi-26))
(define-macro (cut slot . slots)
(let loop ((slots (cons slot slots))

View File

@ -41,7 +41,7 @@
c99-input->info
c99-input->object))
(define mes? (pair? (current-module)))
(define mes? (defined? 'mes))
(define mes-or-reproducible? #t)
(define (cc-amd? info) #f) ; use AMD calling convention?
;; (define %reduced-register-count #f) ; use all registers?

View File

@ -32,5 +32,5 @@
(core:write-error port)
(core:display-error "\n")
(exit (if (equal2? string "foo bar\n") 0 1)))
((if (pair? (current-module)) read-string (@ (ice-9 rdelim) read-string)) port)))
((if (pair? (current-environment)) read-string (@ (ice-9 rdelim) read-string)) port)))
(open-input-string "foo bar\n"))

View File

@ -47,7 +47,7 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (memq x lst)
(if (null? lst) #f

View File

@ -18,7 +18,7 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (caar x) (car (car x)))
(define (cadr x) (car (cdr x)))

View File

@ -21,10 +21,10 @@
(mes
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -21,10 +21,10 @@
(mes
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -21,10 +21,10 @@
(mes
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -23,10 +23,10 @@
;;;;;;;;;;;;;;;
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -20,7 +20,7 @@
(define mes %version)
(define (defined? x)
(module-variable (current-module) x))
(module-variable (current-environment) x))
(define (cond-expand-expander clauses)
(if (defined? (car (car clauses)))
@ -62,10 +62,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)
@ -146,10 +146,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -63,10 +63,10 @@
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(cons (car rest) (core:apply cons* (cdr rest) (current-environment)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(if (null? t) (core:apply f h (current-environment))
(apply f (apply cons* (cons h t)))))
(define (append . rest)

View File

@ -18,7 +18,7 @@
(define-module (guile gc))
(define (R) (reload-module (current-module)))
(define (R) (reload-module (current-environment)))
(define gc-size 10)
(define the-cars (make-vector gc-size '(* . *)))
@ -107,7 +107,7 @@
(display (cell-value x)))))
(define (gc-root)
(filter gc-pair? (module-map (lambda (x y) (variable-ref y)) (current-module)))
(filter gc-pair? (module-map (lambda (x y) (variable-ref y)) (current-environment)))
list1234)
(define new-cars (make-vector gc-size '(* . *)))

View File

@ -309,7 +309,7 @@ expand_variable_ (struct scm *x, struct scm *formals, int top_p) /*:((int
else if (a == cell_symbol_quote)
return cell_unspecified;
else if (a->type == TSYMBOL
&& a != cell_symbol_current_module
&& a != cell_symbol_current_environment
&& a != cell_symbol_primitive_load
&& formal_p (x->car, formals) == 0)
{
@ -550,7 +550,7 @@ apply:
R1 = R1->cdr;
goto call_with_values;
}
if (c == cell_symbol_current_module)
if (c == cell_symbol_current_environment)
{
R1 = R0;
goto vm_return;
@ -726,7 +726,7 @@ eval:
}
else if (t == TSYMBOL)
{
if (R1 == cell_symbol_current_module)
if (R1 == cell_symbol_current_environment)
goto vm_return;
if (R1 == cell_symbol_begin)
goto vm_return;

View File

@ -120,7 +120,7 @@ init_symbols_ () /*:((internal)) */
cell_symbol_sc_expander_alist = init_symbol (g_symbol, TSYMBOL, "*sc-expander-alist*");
cell_symbol_call_with_values = init_symbol (g_symbol, TSYMBOL, "call-with-values");
cell_symbol_call_with_current_continuation = init_symbol (g_symbol, TSYMBOL, "call-with-current-continuation");
cell_symbol_current_module = init_symbol (g_symbol, TSYMBOL, "current-module");
cell_symbol_current_environment = init_symbol (g_symbol, TSYMBOL, "current-environment");
cell_symbol_primitive_load = init_symbol (g_symbol, TSYMBOL, "primitive-load");
cell_symbol_car = init_symbol (g_symbol, TSYMBOL, "car");
cell_symbol_cdr = init_symbol (g_symbol, TSYMBOL, "cdr");
@ -189,7 +189,7 @@ init_symbols () /*:((internal)) */
struct scm *a = cell_nil;
a = acons (cell_symbol_call_with_values, cell_symbol_call_with_values, a);
a = acons (cell_symbol_current_module, cell_symbol_current_module, a);
a = acons (cell_symbol_current_environment, cell_symbol_current_environment, a);
a = acons (cell_symbol_mes_version, make_string0 (MES_VERSION), a);
a = acons (cell_symbol_mes_datadir, make_string0 (g_datadir), a);

View File

@ -28,7 +28,7 @@ exec ${MES-bin/mes} --no-auto-compile -L ${0%/*} -L module -C module -s "$0" "$@
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(define mes? (pair? (current-module)))
(define mes? (pair? (current-environment)))
(gc)
((if mes? core:display display) (gc-stats))
((if mes? core:display display) "\n")

View File

@ -114,10 +114,10 @@ MES_ARENA=${MES_ARENA-10000000} exec ${MES-bin/mes} --no-auto-compile -L ${0%/*}
(exp '(swap foo bar))
(foo "foo")
(bar "bar")
(s (eval sc (current-module)))
(s (eval sc (current-environment)))
(d (syntax-object->datum s))
(e (core:macro-expand d)))
(eval e (current-module))
(eval e (current-environment))
(list foo bar)))))
(pass-if-equal "define-syntax swap! [syntax-case]"