Skip to content

Commit

Permalink
Cleanup of boot.stk
Browse files Browse the repository at this point in the history
Boot should now be OK.

Functions are now defined (and not copied) in the SCHEME module. That
means that the functions used by a closure are searched in the SCHEME
module. This should fix the first problem exposed in @jpellegrini
Issue #367.
  • Loading branch information
Erick Gallesio committed May 13, 2022
1 parent 7f7e7f5 commit 8bed10c
Show file tree
Hide file tree
Showing 3 changed files with 6,249 additions and 6,275 deletions.
25 changes: 10 additions & 15 deletions lib/boot.stk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
;;;;
;;;; Author: Erick Gallesio [[email protected]]
;;;; Creation date: 01-Jan-2000 15:04 (eg)
;;;; Last file update: 12-May-2022 18:24 (eg)
;;;; Last file update: 13-May-2022 14:49 (eg)
;;;;

(define original-input-port (current-input-port))
Expand All @@ -30,13 +30,9 @@
;; Following code is in the STklos module and is needed to ensure STklos
:; bootstap
;;

(include "runtime.stk") ; Definitions necessary for the bootstrap
(include "runtime-macros.stk") ; Macros necessary for the bootstrap
(include "module.stk") ; All the macros for defining modules
(include "compiler.stk") ; VM Compiler
(import STKLOS-COMPILER) ; mainly for "eval"


;; ----------------------------------------------------------------------
;; SCHEME Module
Expand All @@ -55,6 +51,9 @@
(%module-exports-set! (find-module 'SCHEME)
(module-exports (find-module 'STklos)))

;; NOTE: This include MUST be done early (and not earlier). See why.
(include "compiler.stk") ; VM Compiler (this include MUST be done early)


(define-module SCHEME
(include "r5rs.stk") ; R5RS stuff written in Scheme
Expand Down Expand Up @@ -93,11 +92,11 @@
;;
(import STKLOS-OBJECT MBE SRFI-0 REPL REPL-READLINE)


;;
;; Add all the exported bindings in SCHEME module to STklos. Don't use import
;; here, since import makes new bindings read-only (and we want that bindings
;; in STklos can be broken if needed).
;;
(let ((STklos (find-module 'STklos))
(SCHEME (find-module 'SCHEME)))
(for-each (lambda(x)
Expand All @@ -111,34 +110,30 @@
(include "./scheme/base.stk")
(include "./scheme/write.stk")


;;
;; It's time to lock the SCHEME module, that is make bindings in it read-only
;; and forbid further definitions.
(define-module SCHEME
(import STKLOS-OBJECT MBE SRFI-0 REPL REPL-READLINE) ; as in STklos
(import STKLOS-COMPILER STKLOS-OBJECT MBE SRFI-0 REPL REPL-READLINE)

;; During he bootstap, the module SCHEME is present and all the definitions
;; made above (yes above!!), need an unlocked SCHEME module. So, the module
;; SCHEME is closed only for user programs (in this case STKLOS_BUILDING is
;; not defined)
(unless (getenv "STKLOS_BUILDING")
;; We are not bootstapping
(module-lock! (find-module 'SCHEME))))

(module-lock! (current-module))))


;; ======================================================================
;;
;; Define exception handlers, analyze options and eventually launch REPL
;; Define exception handlers, analyze options
;;
;; Execute the REPL only if a file was not given on the command line
;; ======================================================================

;; Execute the REPL only if a file was not given on the command line
(define %before-exit-hook void)

;; A main function which will probably overloaded by the user
(define main void)
(define main void) ;; A main function which will probably overloaded by the user

;; ----------------------------------------------------------------------
;; %display-backtrace ...
Expand Down
11,816 changes: 5,899 additions & 5,917 deletions src/boot.c

Large diffs are not rendered by default.

Loading

0 comments on commit 8bed10c

Please sign in to comment.