From ad712e431d2ebce1a2c49b8299275c2f4cf637cf Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Aug 2005 05:33:43 +0000 Subject: [PATCH] bootstrap cleanup --- library/bootstrap/boot-stage2.factor | 151 ++++++++++++++++++++++++++- library/bootstrap/boot-stage3.factor | 131 ----------------------- library/bootstrap/boot-stage4.factor | 54 ---------- library/bootstrap/init.factor | 10 +- 4 files changed, 156 insertions(+), 190 deletions(-) delete mode 100644 library/bootstrap/boot-stage3.factor delete mode 100644 library/bootstrap/boot-stage4.factor diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index 3727fcc9e7..18be3546a9 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. -USING: alien assembler command-line compiler errors generic -hashtables io kernel lists memory namespaces parser sequences words ; +USING: alien assembler command-line compiler compiler-backend +errors generic hashtables io io-internals kernel lists math +memory namespaces parser sequences words ; : pull-in ( ? list -- ) swap [ @@ -32,4 +33,148 @@ cpu "ppc" = [ "/library/compiler/ppc/alien.factor" ] pull-in -"/library/bootstrap/boot-stage3.factor" run-resource +"Compiling base..." print + +"statically-linked" get [ + unix? [ + "sdl" "libSDL.so" "cdecl" add-library + "sdl-gfx" "libSDL_gfx.so" "cdecl" add-library + "sdl-ttf" "libSDL_ttf.so" "cdecl" add-library + ] when + + win32? [ + "kernel32" "kernel32.dll" "stdcall" add-library + "user32" "user32.dll" "stdcall" add-library + "gdi32" "gdi32.dll" "stdcall" add-library + "winsock" "ws2_32.dll" "stdcall" add-library + "mswsock" "mswsock.dll" "stdcall" add-library + "libc" "msvcrt.dll" "cdecl" add-library + "sdl" "SDL.dll" "cdecl" add-library + "sdl-gfx" "SDL_gfx.dll" "cdecl" add-library + "sdl-ttf" "SDL_ttf.dll" "cdecl" add-library + ] when +] unless + +: compile? "compile" get supported-cpu? and ; + +compile? [ + \ car compile + \ * compile + \ = compile + \ string>number compile + \ number>string compile + \ scan compile + \ (generate) compile +] when + +"Loading more library code..." print + +t [ + "/library/alien/malloc.factor" + "/library/io/buffer.factor" + + "/library/math/constants.factor" + "/library/math/pow.factor" + "/library/math/trig-hyp.factor" + "/library/math/arc-trig-hyp.factor" + "/library/math/random.factor" + + "/library/in-thread.factor" + + "/library/io/directories.factor" + "/library/io/binary.factor" + + "/library/eval-catch.factor" + "/library/tools/listener.factor" + "/library/tools/word-tools.factor" + "/library/syntax/see.factor" + "/library/test/test.factor" + "/library/tools/walker.factor" + "/library/tools/annotations.factor" + "/library/tools/inspector.factor" + "/library/bootstrap/image.factor" + + "/library/io/logging.factor" + + "/library/tools/telnetd.factor" + "/library/tools/jedit.factor" + + "/library/httpd/load.factor" + "/library/sdl/load.factor" + "/library/ui/load.factor" + "/library/help/tutorial.factor" +] pull-in + +compile? [ + unix? [ + "/library/unix/types.factor" + ] pull-in + + os "freebsd" = [ + "/library/unix/syscalls-freebsd.factor" + ] pull-in + + os "linux" = [ + "/library/unix/syscalls-linux.factor" + ] pull-in + + os "macosx" = [ + "/library/unix/syscalls-macosx.factor" + ] pull-in + + unix? [ + "/library/unix/syscalls.factor" + "/library/unix/io.factor" + "/library/unix/sockets.factor" + "/library/unix/files.factor" + ] pull-in + + os "win32" = [ + "/library/win32/win32-io.factor" + "/library/win32/win32-errors.factor" + "/library/win32/winsock.factor" + "/library/win32/win32-io-internals.factor" + "/library/win32/win32-stream.factor" + "/library/win32/win32-server.factor" + "/library/bootstrap/win32-io.factor" + ] pull-in +] when + +"Building cross-reference database..." print +recrossref + +compile? [ + "Compiling system..." print + compile-all + terpri + "Unless you're working on the compiler, ignore the errors above." print + "Not every word compiles, by design." print + terpri + "Initializing native I/O..." print + init-io +] when + +[ + boot + run-user-init + "shell" get [ "shells" ] search execute + 0 exit +] set-boot + +0 [ compiled? [ 1 + ] when ] each-word +number>string write " words compiled" print + +0 [ drop 1 + ] each-word +number>string write " words total" print + +"Total bootstrap GC time: " write gc-time +number>string write " ms" print + +"Bootstrapping is complete." print +"Now, you can run ./f factor.image" print + +"factor.image" save-image +0 exit + +FORGET: pull-in +FORGET: compile? diff --git a/library/bootstrap/boot-stage3.factor b/library/bootstrap/boot-stage3.factor deleted file mode 100644 index ca736560ba..0000000000 --- a/library/bootstrap/boot-stage3.factor +++ /dev/null @@ -1,131 +0,0 @@ -! Copyright (C) 2004, 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. -USING: alien assembler command-line compiler compiler-backend -compiler-frontend inference io-internals kernel lists math -namespaces parser sequences io words ; - -"Compiling base..." print - -"statically-linked" get [ - unix? [ - "sdl" "libSDL.so" "cdecl" add-library - "sdl-gfx" "libSDL_gfx.so" "cdecl" add-library - "sdl-ttf" "libSDL_ttf.so" "cdecl" add-library - ] when - - win32? [ - "kernel32" "kernel32.dll" "stdcall" add-library - "user32" "user32.dll" "stdcall" add-library - "gdi32" "gdi32.dll" "stdcall" add-library - "winsock" "ws2_32.dll" "stdcall" add-library - "mswsock" "mswsock.dll" "stdcall" add-library - "libc" "msvcrt.dll" "cdecl" add-library - "sdl" "SDL.dll" "cdecl" add-library - "sdl-gfx" "SDL_gfx.dll" "cdecl" add-library - "sdl-ttf" "SDL_ttf.dll" "cdecl" add-library - ] when -] unless - -default-cli-args -parse-command-line -init-assembler - -: compile? "compile" get supported-cpu? and ; - -compile? [ - \ car compile - \ * compile - \ = compile - \ string>number compile - \ number>string compile - \ scan compile - \ (generate) compile -] when - -"Loading more library code..." print - -t [ - "/library/alien/malloc.factor" - "/library/io/buffer.factor" - - "/library/math/constants.factor" - "/library/math/pow.factor" - "/library/math/trig-hyp.factor" - "/library/math/arc-trig-hyp.factor" - "/library/math/random.factor" - - "/library/in-thread.factor" - - "/library/io/directories.factor" - "/library/io/binary.factor" - - "/library/eval-catch.factor" - "/library/tools/listener.factor" - "/library/tools/word-tools.factor" - "/library/syntax/see.factor" - "/library/test/test.factor" - "/library/tools/walker.factor" - "/library/tools/annotations.factor" - "/library/tools/inspector.factor" - "/library/bootstrap/image.factor" - - "/library/io/logging.factor" - - "/library/tools/telnetd.factor" - "/library/tools/jedit.factor" - - "/library/httpd/load.factor" - "/library/sdl/load.factor" - "/library/ui/load.factor" - "/library/help/tutorial.factor" -] pull-in - -compile? [ - unix? [ - "/library/unix/types.factor" - ] pull-in - - os "freebsd" = [ - "/library/unix/syscalls-freebsd.factor" - ] pull-in - - os "linux" = [ - "/library/unix/syscalls-linux.factor" - ] pull-in - - os "macosx" = [ - "/library/unix/syscalls-macosx.factor" - ] pull-in - - unix? [ - "/library/unix/syscalls.factor" - "/library/unix/io.factor" - "/library/unix/sockets.factor" - "/library/unix/files.factor" - ] pull-in - - os "win32" = [ - "/library/win32/win32-io.factor" - "/library/win32/win32-errors.factor" - "/library/win32/winsock.factor" - "/library/win32/win32-io-internals.factor" - "/library/win32/win32-stream.factor" - "/library/win32/win32-server.factor" - "/library/bootstrap/win32-io.factor" - ] pull-in -] when - -"Building cross-reference database..." print -recrossref - -compile? [ - "Compiling system..." print - compile-all - "Initializing native I/O..." print - init-io -] when - -FORGET: pull-in -FORGET: compile? - -"/library/bootstrap/boot-stage4.factor" dup print run-resource diff --git a/library/bootstrap/boot-stage4.factor b/library/bootstrap/boot-stage4.factor deleted file mode 100644 index 5a13a19533..0000000000 --- a/library/bootstrap/boot-stage4.factor +++ /dev/null @@ -1,54 +0,0 @@ -! Copyright (C) 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. -IN: kernel -USING: alien assembler command-line compiler console errors -generic inference kernel-internals listener lists math memory -namespaces parser presentation prettyprint random io words ; - -"Bootstrap stage 4..." print - -: warm-boot ( -- ) - #! A fully bootstrapped image has this as the boot - #! quotation. - init-assembler - init-error-handler - default-cli-args - parse-command-line - "null-stdio" get [ << null-stream f >> stdio set ] when ; - -: shell ( str -- ) - #! This handles the -shell: cli argument. - [ "shells" ] search execute ; - -[ - boot - warm-boot - run-user-init - "shell" get shell - 0 exit -] set-boot - -warm-boot - -terpri -"Unless you're working on the compiler, ignore the errors above." print -"Not every word compiles, by design." print -terpri - -0 [ compiled? [ 1 + ] when ] each-word -number>string write " words compiled" print - -0 [ drop 1 + ] each-word -number>string write " words total" print - -"Total bootstrap GC time: " write gc-time -number>string write " ms" print - -"Bootstrapping is complete." print -"Now, you can run ./f factor.image" print - -! Save a bit of space -global [ stdio off ] bind - -"factor.image" save-image -0 exit diff --git a/library/bootstrap/init.factor b/library/bootstrap/init.factor index ad568c73c7..6d51e545d9 100644 --- a/library/bootstrap/init.factor +++ b/library/bootstrap/init.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: kernel -USING: io-internals namespaces parser io threads words ; +USING: assembler command-line errors io io-internals namespaces +parser threads words ; : boot ( -- ) #! Initialize an interpreter with the basic services. @@ -9,4 +10,9 @@ USING: io-internals namespaces parser io threads words ; init-threads init-io "HOME" os-env [ "." ] unless* "~" set - init-search-path ; + init-search-path + init-assembler + init-error-handler + default-cli-args + parse-command-line + "null-stdio" get [ << null-stream f >> stdio set ] when ;