From f7dacce8b03b57d89709a74d9cc7185ff6a1ae15 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Thu, 25 Apr 2013 14:00:35 +0100 Subject: [PATCH] Fixes to bootstrap --- boot.lisp | 1 - compat.lisp | 5 +++-- ecmalisp.lisp | 29 ++++++++++++++++++----------- print.lisp | 30 +++++++++++------------------- utils.lisp | 2 ++ 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/boot.lisp b/boot.lisp index 1663ec4..3454c65 100644 --- a/boot.lisp +++ b/boot.lisp @@ -848,7 +848,6 @@ (defun concat (&rest strs) (!reduce #'concat-two strs :initial-value "")) - (defun values-list (list) (values-array (list-to-vector list))) diff --git a/compat.lisp b/compat.lisp index f51fc27..184c5dd 100644 --- a/compat.lisp +++ b/compat.lisp @@ -44,5 +44,6 @@ (defun aset (array idx value) (setf (aref array idx) value)) -(defun concat (&rest strs) - (apply #'concatenate 'string strs)) +(eval-when-compile + (defun concat (&rest strs) + (apply #'concatenate 'string strs))) diff --git a/ecmalisp.lisp b/ecmalisp.lisp index 45b22f9..a7aa677 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -16,19 +16,25 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -(eval-when (:load-toplevel :compile-toplevel :execute) - (defvar *source* - '(("boot.lisp" :target) - ("compat" :host) - ("utils.lisp" :both) - ("print.lisp" :both) - ("read.lisp" :both) - ("compiler.lisp" :both) - ("toplevel.lisp" :target))) +(defvar *source* + '(("boot" :target) + ("compat" :host) + ("utils" :both) + ("print" :target) + ("read" :both) + ("compiler" :both) + ("toplevel" :target))) +;;; Compile ecmalisp into the host +(with-compilation-unit () (dolist (input *source*) (when (member (cadr input) '(:host :both)) - (load (car input))))) + (compile-file (car input))))) + +;;; Load ecmalisp into the host +(dolist (input *source*) + (when (member (cadr input) '(:host :both)) + (load (car input)))) (defun read-whole-file (filename) (with-open-file (in filename) @@ -60,4 +66,5 @@ (write-string (read-whole-file "prelude.js") out) (dolist (input *source*) (when (member (cadr input) '(:target :both)) - (ls-compile-file (car input) out))))) + (let ((file (make-pathname :type "lisp" :defaults (car input)))) + (ls-compile-file file out)))))) diff --git a/print.lisp b/print.lisp index c63e736..9d36936 100644 --- a/print.lisp +++ b/print.lisp @@ -18,9 +18,7 @@ ;;; Printer -(defvar *newline* (string (code-char 10))) - -(defun !print1-to-string (form) +(defun prin1-to-string (form) (cond ((symbolp form) (multiple-value-bind (symbol foundp) @@ -58,21 +56,15 @@ (t (concat "#")))) +(defun write-line (x) + (write-string x) + (write-string *newline*) + x) -#+ecmalisp -(progn - (defun prin1-to-string (form) - (!print1-to-string form)) - - (defun write-line (x) - (write-string x) - (write-string *newline*) - x) - - (defun warn (string) - (write-string "WARNING: ") - (write-line string)) +(defun warn (string) + (write-string "WARNING: ") + (write-line string)) - (defun print (x) - (write-line (prin1-to-string x)) - x)) +(defun print (x) + (write-line (prin1-to-string x)) + x) diff --git a/utils.lisp b/utils.lisp index 4a693f9..31afe28 100644 --- a/utils.lisp +++ b/utils.lisp @@ -16,6 +16,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . +(defvar *newline* (string (code-char 10))) + (defmacro concatf (variable &body form) `(setq ,variable (concat ,variable (progn ,@form)))) -- 1.7.10.4