Fix oversight in the bootstrap procedure

Stage 0 is supposed to emit compiled versions of system.scm and
compiler.scm. The compiler.scm bytecode wasn't emitted properly
because the emitter put the two files' bytecode in two separate C
variables instead of concatenating them into the same variable as they
should be.
This commit is contained in:
Lassi Kortela 2019-08-14 00:44:24 +03:00
parent cccbe54bb5
commit d781c65862
5 changed files with 1439 additions and 1517 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
(define (dump-buffer-as-c-literal buf)
(define (dump-buffers-as-c-literal . bufs)
(princ "char boot_image[] = \"")
(let next ((i 0))
(let loop-bufs ((bufs bufs))
(if (not (null? bufs))
(begin (let ((buf (car bufs)))
(let loop-buf-bytes ((i 0))
(let ((char (read-u8 buf)))
(if (not (io.eof? buf))
(let ((code (+ char 0)))
@ -8,5 +11,6 @@
(princ "\\x")
(if (< code #x10) (princ "0"))
(princ (number->string code 16))
(next (+ i 1))))))
(loop-buf-bytes (+ i 1)))))))
(loop-bufs (cdr bufs)))))
(princ "\";\n"))

View File

@ -19,6 +19,6 @@
(io.seek out 0)
out))
(for-each (lambda (file)
(dump-buffer-as-c-literal (compile-file->buffer file)))
(cdr *argv*))
(dump-buffers-as-c-literal
(compile-file->buffer "system.scm")
(compile-file->buffer "compiler.scm"))

View File

@ -4,4 +4,4 @@
(load "compiler.scm")
(load "dump.scm")
(dump-buffer-as-c-literal (system-image->buffer))
(dump-buffers-as-c-literal (system-image->buffer))

View File

@ -113,8 +113,7 @@ cd ../scheme-core
echo "Entering directory '$PWD'"
echo "Creating stage 0 boot file..."
set -x
../"$builddir"/upscheme mkboot0.scm system.scm compiler.scm \
>../scheme-boot/boot_image.h.new
../"$builddir"/upscheme mkboot0.scm >../scheme-boot/boot_image.h.new
mv ../scheme-boot/boot_image.h.new ../scheme-boot/boot_image.h
{ set +x; } 2>/dev/null
@ -129,8 +128,7 @@ cd ../scheme-core
echo "Entering directory '$PWD'"
echo "Creating stage 1 boot file..."
set -x
../"$builddir"/upscheme mkboot1.scm \
>../scheme-boot/boot_image.h.new
../"$builddir"/upscheme mkboot1.scm >../scheme-boot/boot_image.h.new
mv ../scheme-boot/boot_image.h.new ../scheme-boot/boot_image.h
{ set +x; } 2>/dev/null