]> gitweb.factorcode.org Git - factor.git/commitdiff
bootstrap: some cleanup, move stage1 to basis/bootstrap/
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 21 Jan 2022 19:26:03 +0000 (11:26 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 21 Jan 2022 19:26:03 +0000 (11:26 -0800)
this keeps it all together and imho makes it easier to understand

23 files changed:
basis/bootstrap/assembler/arm.32.unix.factor
basis/bootstrap/assembler/arm.32.windows.factor
basis/bootstrap/assembler/arm.64.unix.factor
basis/bootstrap/assembler/arm.64.windows.factor
basis/bootstrap/assembler/ppc.32.linux.factor
basis/bootstrap/assembler/ppc.64.linux.factor
basis/bootstrap/assembler/x86.32.unix.factor
basis/bootstrap/assembler/x86.32.windows.factor
basis/bootstrap/assembler/x86.64.unix.factor
basis/bootstrap/assembler/x86.64.windows.factor
basis/bootstrap/image/image.factor
basis/bootstrap/image/primitives/primitives-docs.factor
basis/bootstrap/layouts.factor [new file with mode: 0644]
basis/bootstrap/primitives.factor [new file with mode: 0644]
basis/bootstrap/stage1.factor [new file with mode: 0644]
basis/bootstrap/stage2.factor
basis/bootstrap/summary.txt [new file with mode: 0644]
basis/bootstrap/syntax.factor [new file with mode: 0644]
core/bootstrap/layouts.factor [deleted file]
core/bootstrap/primitives.factor [deleted file]
core/bootstrap/stage1.factor [deleted file]
core/bootstrap/summary.txt [deleted file]
core/bootstrap/syntax.factor [deleted file]

index e8db0416ee0d0f74e843435d952c40aaae128b9b..d8945220c6d31b1234e08a76c5cf5ea98056ff48 100644 (file)
@@ -3,6 +3,6 @@
 USING: kernel parser sequences ;
 IN: bootstrap.assembler.arm
 
-<< "vocab:bootstrap/assembler/arm.unix.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.32.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.unix.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.32.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.factor" parse-file suffix! >> call
index 70f20056ca2265651d3d4c8e200669101cf46c89..ae11ab5f8de14c2b8352b986f56f966a2fd2e596 100644 (file)
@@ -3,6 +3,6 @@
 USING: kernel parser sequences ;
 IN: bootstrap.assembler.arm
 
-<< "vocab:bootstrap/assembler/arm.windows.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.32.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.windows.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.32.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.factor" parse-file suffix! >> call
index 4f4fe7d1b94f80820c9bb0b10016ccd34dff0a72..69a1c87a779265e5d48dfa6f50bcc69a550a5a00 100644 (file)
@@ -56,6 +56,6 @@ IN: bootstrap.assembler.arm
 : arg4 ( -- reg ) X3 ;
 : red-zone-size ( -- n ) 16 ;
 
-<< "vocab:bootstrap/assembler/arm.unix.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.64.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.unix.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.64.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.factor" parse-file suffix! >> call
index 5f2938a369d4ceed82ba797c5c0e8025d1675e6f..16480903e5f7edbca1b01bbf3bcba71c64f9046d 100644 (file)
@@ -4,6 +4,6 @@ USING: kernel parser sequences ;
 IN: bootstrap.assembler.arm
 
 
-<< "vocab:bootstrap/assembler/arm.windows.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.64.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/arm.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.windows.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.64.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/arm.factor" parse-file suffix! >> call
index 1f019587a276316ae035fd7a55e0d22b99f14a86..328b14e61d9d67ae2970320d0eb5dafbebf98437 100644 (file)
@@ -69,5 +69,5 @@ CONSTANT: frame-reg 31
 : param-size ( -- n ) 32 ;
 : saved-int-regs-size ( -- n ) 96 ;
 
-<< "vocab:bootstrap/assembler/ppc.factor" parse-file suffix! >>
+<< "resource:basis/bootstrap/assembler/ppc.factor" parse-file suffix! >>
 call
index bb1d661ca1aabed965fde3671468a0e4c9f5c3dd..1915688f67d8ac023625f550a2d61cd77124243e 100644 (file)
@@ -76,5 +76,5 @@ CONSTANT: frame-reg 31
 : param-size ( -- n ) 64 ;
 : saved-int-regs-size ( -- n ) 192 ;
 
-<< "vocab:bootstrap/assembler/ppc.factor" parse-file suffix! >>
+<< "resource:basis/bootstrap/assembler/ppc.factor" parse-file suffix! >>
 call
index aff19eb7d11290f9e930e9dc444ab4cd48933788..ce7e1b6779c8c84381371f699793a029dccb7d4a 100644 (file)
@@ -3,6 +3,6 @@
 USING: kernel parser sequences ;
 IN: bootstrap.assembler.x86
 
-<< "vocab:bootstrap/assembler/x86.unix.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/x86.32.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/x86.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.unix.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.32.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.factor" parse-file suffix! >> call
index d7e6e58a93ea9f89c793dc29fcccfedf65242861..c190b5611a70c9201763edf6dde8670dd42f127c 100644 (file)
@@ -8,7 +8,7 @@ IN: bootstrap.assembler.x86
 : tib-segment ( -- ) FS ;
 : tib-temp ( -- reg ) EAX ;
 
-<< "vocab:bootstrap/assembler/x86.windows.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.windows.factor" parse-file suffix! >> call
 
 : jit-install-seh ( -- )
     ! VM pointer must be in vm-reg already
@@ -34,5 +34,5 @@ IN: bootstrap.assembler.x86
     ! Store exception record in TIB.
     tib-exception-list-offset [] tib-temp tib-segment MOV ;
 
-<< "vocab:bootstrap/assembler/x86.32.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/x86.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.32.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.factor" parse-file suffix! >> call
index e21962ed2a1debe22beffc671ed634a3bd7a8773..55e66759dc26dc6ce39d8eedcb661ff264d76e99 100644 (file)
@@ -16,6 +16,6 @@ IN: bootstrap.assembler.x86
 : arg4 ( -- reg ) RCX ;
 : red-zone-size ( -- n ) 128 ;
 
-<< "vocab:bootstrap/assembler/x86.unix.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/x86.64.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/x86.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.unix.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.64.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.factor" parse-file suffix! >> call
index ec2fbf4dcd1f153f3a5abfff57b3202137fb4ab9..8e981557e7043f519dbbcea782885e965bf86a75 100644 (file)
@@ -22,6 +22,6 @@ DEFER: stack-reg
 
 : red-zone-size ( -- n ) 0 ;
 
-<< "vocab:bootstrap/assembler/x86.windows.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/x86.64.factor" parse-file suffix! >> call
-<< "vocab:bootstrap/assembler/x86.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.windows.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.64.factor" parse-file suffix! >> call
+<< "resource:basis/bootstrap/assembler/x86.factor" parse-file suffix! >> call
index 6bf93c7636f067ff99b62835242b2751d6598e2e..8a9ec7348e8398c6465c2ab08983e6a797e1be59 100644 (file)
@@ -531,7 +531,7 @@ PRIVATE>
         { auto-use? f }
     } assoc-union! [
         H{ } clone special-objects set
-        "resource:/core/bootstrap/stage1.factor" run-file
+        "resource:basis/bootstrap/stage1.factor" run-file
         build-image
         write-image
     ] with-variables ;
index ce435ac5a73a529d0e5fd3bfb36cd698a254a00b..3c6d97ec290907821900672441eb06b4e5a71258 100644 (file)
@@ -19,7 +19,7 @@ HELP: primitive-quot
 { $description "Creates the defining quotation for the primitive. If 'vm-func' is a string, then it is prefixed with 'primitive_' and a quotation calling that C++ function is generated." } ;
 
 ARTICLE: "bootstrap.image.primitives" "Bootstrap primitives"
-"This vocab contains utilities for declaring primitives to be added to the bootstrap image. It is used by the file " { $snippet "resource:core/bootstrap/primitives.factor" }
+"This vocab contains utilities for declaring primitives to be added to the bootstrap image. It is used by the file " { $snippet "resource:basis/bootstrap/primitives.factor" }
 $nl
 { $link all-primitives } " is an assoc where all primitives are declared. See that constant for a description of the format." ;
 
diff --git a/basis/bootstrap/layouts.factor b/basis/bootstrap/layouts.factor
new file mode 100644 (file)
index 0000000..6ff54d4
--- /dev/null
@@ -0,0 +1,34 @@
+! Copyright (C) 2007, 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien arrays byte-arrays kernel layouts math namespaces
+quotations strings words ;
+
+16 data-alignment set
+
+0b1111 tag-mask set
+4 tag-bits set
+
+32 mega-cache-size set
+
+! Type tags, should be kept in sync with:
+!   vm/layouts.hpp
+H{
+    { fixnum 0 }
+    { POSTPONE: f 1 }
+    { array 2 }
+    { float 3 }
+    { quotation 4 }
+    { bignum 5 }
+    { alien 6 }
+    { tuple 7 }
+    { wrapper 8 }
+    { byte-array 9 }
+    { callstack 10 }
+    { string 11 }
+    { word 12 }
+    { dll 13 }
+} type-numbers set
+
+14 num-types set
+
+2 header-bits set
diff --git a/basis/bootstrap/primitives.factor b/basis/bootstrap/primitives.factor
new file mode 100644 (file)
index 0000000..85092c8
--- /dev/null
@@ -0,0 +1,331 @@
+! Copyright (C) 2004, 2010 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays assocs bootstrap.image.primitives
+bootstrap.image.private classes classes.builtin classes.intersection
+classes.predicate classes.private classes.singleton classes.tuple
+classes.tuple.private classes.union combinators compiler.units io
+kernel kernel.private layouts make math math.private namespaces parser
+quotations sequences slots source-files splitting vocabs vocabs.loader
+words ;
+IN: bootstrap.primitives
+
+"* Creating primitives and basic runtime structures..." print flush
+
+H{ } clone sub-primitives set
+
+"resource:basis/bootstrap/syntax.factor" parse-file
+
+: asm-file ( arch -- file )
+    "-" split reverse "." join
+    "resource:basis/bootstrap/assembler/" ".factor" surround ;
+
+architecture get asm-file parse-file
+
+"resource:basis/bootstrap/layouts.factor" parse-file
+
+! Now we have ( syntax-quot arch-quot layouts-quot ) on the stack
+
+! Bring up a bare cross-compiling vocabulary.
+"syntax" lookup-vocab vocab-words-assoc bootstrap-syntax set
+
+H{ } clone dictionary set
+H{ } clone root-cache set
+H{ } clone source-files set
+H{ } clone update-map set
+H{ } clone implementors-map set
+
+init-caches
+
+bootstrapping? on
+
+call( -- ) ! layouts quot
+call( -- ) ! arch quot
+
+! Vocabulary for slot accessors
+"accessors" create-vocab drop
+
+! After we execute bootstrap/layouts
+num-types get f <array> builtins set
+
+[
+
+call( -- ) ! syntax-quot
+
+! create-word some empty vocabs where the below primitives and
+! classes will go
+{
+    "alien"
+    "alien.accessors"
+    "alien.libraries"
+    "alien.private"
+    "arrays"
+    "byte-arrays"
+    "classes.private"
+    "classes.tuple"
+    "classes.tuple.private"
+    "classes.predicate"
+    "compiler.units"
+    "continuations.private"
+    "generic.single"
+    "generic.single.private"
+    "growable"
+    "hashtables"
+    "hashtables.private"
+    "io"
+    "io.files"
+    "io.files.private"
+    "io.streams.c"
+    "locals.backend"
+    "kernel"
+    "kernel.private"
+    "math"
+    "math.parser.private"
+    "math.private"
+    "memory"
+    "memory.private"
+    "quotations"
+    "quotations.private"
+    "sbufs"
+    "sbufs.private"
+    "scratchpad"
+    "sequences"
+    "sequences.private"
+    "slots.private"
+    "strings"
+    "strings.private"
+    "system"
+    "system.private"
+    "threads.private"
+    "tools.dispatch.private"
+    "tools.memory.private"
+    "tools.profiler.sampling.private"
+    "words"
+    "words.private"
+    "vectors"
+    "vectors.private"
+    "vm"
+} [ create-vocab drop ] each
+
+! Builtin classes
+: lookup-type-number ( word -- n )
+    [ target-word ] with-global type-number ;
+
+: register-builtin ( class -- )
+    [ dup lookup-type-number "type" set-word-prop ]
+    [ dup "type" word-prop builtins get set-nth ]
+    [ f f f builtin-class define-class ]
+    tri ;
+
+: prepare-slots ( slots -- slots' )
+    [ [ dup pair? [ first2 create-word ] when ] map ] map ;
+
+: define-builtin-slots ( class slots -- )
+    prepare-slots make-slots 1 finalize-slots
+    [ "slots" set-word-prop ] [ define-accessors ] 2bi ;
+
+: define-builtin-predicate ( class -- )
+    dup class>type [ eq? ] curry [ tag ] prepend define-predicate ;
+
+: define-builtin ( symbol slotspec -- )
+    [ [ define-builtin-predicate ] keep ] dip define-builtin-slots ;
+
+{
+    { "alien" "alien" }
+    { "array" "arrays" }
+    { "bignum" "math" }
+    { "byte-array" "byte-arrays" }
+    { "callstack" "kernel" }
+    { "dll" "alien" }
+    { "fixnum" "math" }
+    { "float" "math" }
+    { "quotation" "quotations" }
+    { "string" "strings" }
+    { "tuple" "kernel" }
+    { "word" "words" }
+    { "wrapper" "kernel" }
+} [ create-word register-builtin ] assoc-each
+
+"f" "syntax" lookup-word register-builtin
+
+! We need this before defining c-ptr below
+"f" "syntax" lookup-word { } define-builtin
+
+"f" "syntax" create-word [ not ] "predicate" set-word-prop
+"f?" "syntax" vocab-words-assoc delete-at
+
+"t" "syntax" lookup-word define-singleton-class
+
+! Some unions
+"c-ptr" "alien" create-word [
+    "alien" "alien" lookup-word ,
+    "f" "syntax" lookup-word ,
+    "byte-array" "byte-arrays" lookup-word ,
+] { } make define-union-class
+
+"integer" "math" create-word
+"fixnum" "math" lookup-word "bignum" "math" lookup-word 2array
+define-union-class
+
+! Two predicate classes used for declarations.
+"array-capacity" "sequences.private" create-word
+"fixnum" "math" lookup-word
+[
+    [ dup 0 fixnum>= ] %
+    bootstrap-max-array-capacity <fake-bignum> [ fixnum<= ] curry ,
+    [ [ drop f ] if ] %
+] [ ] make
+define-predicate-class
+
+"array-capacity" "sequences.private" lookup-word
+[ >fixnum ] bootstrap-max-array-capacity <fake-bignum> [ fixnum-bitand ] curry append
+"coercer" set-word-prop
+
+"integer-array-capacity" "sequences.private" create-word
+"integer" "math" lookup-word
+[
+    [ dup 0 >= ] %
+    bootstrap-max-array-capacity <fake-bignum> [ <= ] curry ,
+    [ [ drop f ] if ] %
+] [ ] make
+define-predicate-class
+
+! Catch-all class for providing a default method.
+"object" "kernel" create-word
+[ f f { } intersection-class define-class ]
+[ [ drop t ] "predicate" set-word-prop ]
+bi
+
+"object?" "kernel" vocab-words-assoc delete-at
+
+! Empty class with no instances
+"null" "kernel" create-word
+[ f { } f union-class define-class ]
+[ [ drop f ] "predicate" set-word-prop ]
+bi
+
+"null?" "kernel" vocab-words-assoc delete-at
+
+"fixnum" "math" create-word { } define-builtin
+"fixnum" "math" create-word "integer>fixnum-strict" "math" create-word 1quotation "coercer" set-word-prop
+
+"bignum" "math" create-word { } define-builtin
+"bignum" "math" create-word ">bignum" "math" create-word 1quotation "coercer" set-word-prop
+
+"float" "math" create-word { } define-builtin
+"float" "math" create-word ">float" "math" create-word 1quotation "coercer" set-word-prop
+
+"array" "arrays" create-word {
+    { "length" { "array-capacity" "sequences.private" } read-only }
+} define-builtin
+
+"wrapper" "kernel" create-word {
+    { "wrapped" read-only }
+} define-builtin
+
+"string" "strings" create-word {
+    { "length" { "array-capacity" "sequences.private" } read-only }
+    "aux"
+} define-builtin
+
+"quotation" "quotations" create-word {
+    { "array" { "array" "arrays" } read-only }
+    "cached-effect"
+    "cache-counter"
+} define-builtin
+
+"dll" "alien" create-word {
+    { "path" { "byte-array" "byte-arrays" } read-only }
+} define-builtin
+
+"alien" "alien" create-word {
+    { "underlying" { "c-ptr" "alien" } read-only }
+    "expired"
+} define-builtin
+
+"word" "words" create-word {
+    { "hashcode" { "fixnum" "math" } }
+    "name"
+    "vocabulary"
+    { "def" { "quotation" "quotations" } initial: [ ] }
+    "props"
+    "pic-def"
+    "pic-tail-def"
+    { "sub-primitive" read-only }
+} define-builtin
+
+"byte-array" "byte-arrays" create-word {
+    { "length" { "array-capacity" "sequences.private" } read-only }
+} define-builtin
+
+"callstack" "kernel" create-word { } define-builtin
+
+"tuple" "kernel" create-word
+[ { } define-builtin ]
+[ define-tuple-layout ]
+bi
+
+! create-word special tombstone values
+"tombstone" "hashtables.private" create-word
+tuple
+{ "state" } define-tuple-class
+
+"+empty+" "hashtables.private" create-word
+{ f } "tombstone" "hashtables.private" lookup-word
+slots>tuple 1quotation ( -- value ) define-inline
+
+"+tombstone+" "hashtables.private" create-word
+{ t } "tombstone" "hashtables.private" lookup-word
+slots>tuple 1quotation ( -- value ) define-inline
+
+! Some tuple classes
+
+"curried" "kernel" create-word
+tuple
+{
+    { "obj" read-only }
+    { "quot" read-only }
+} prepare-slots define-tuple-class
+
+"curry" "kernel" create-word
+{
+    [ f "inline" set-word-prop ]
+    [ make-flushable ]
+} cleave
+
+"curry" "kernel" lookup-word
+[
+    callable instance-check-quot %
+    "curried" "kernel" lookup-word tuple-layout ,
+    \ <tuple-boa> ,
+] [ ] make
+( obj quot -- curry ) define-declared
+
+"composed" "kernel" create-word
+tuple
+{
+    { "first" read-only }
+    { "second" read-only }
+} prepare-slots define-tuple-class
+
+"compose" "kernel" create-word
+{
+    [ f "inline" set-word-prop ]
+    [ make-flushable ]
+} cleave
+
+"compose" "kernel" lookup-word
+[
+    callable instance-check-quot [ dip ] curry %
+    callable instance-check-quot %
+    "composed" "kernel" lookup-word tuple-layout ,
+    \ <tuple-boa> ,
+] [ ] make
+( quot1 quot2 -- compose ) define-declared
+
+"* Declaring primitives..." print flush
+all-primitives create-primitives
+
+! Bump build number
+"build" "kernel" create-word build 1 + [ ] curry ( -- n ) define-declared
+
+] with-compilation-unit
diff --git a/basis/bootstrap/stage1.factor b/basis/bootstrap/stage1.factor
new file mode 100644 (file)
index 0000000..0e9c805
--- /dev/null
@@ -0,0 +1,59 @@
+! Copyright (C) 2004, 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs bootstrap.image.private hash-sets hashtables init
+io io.files kernel kernel.private make memory namespaces parser
+parser.notes sequences system vocabs vocabs.loader ;
+
+"Bootstrap stage 1..." print flush
+
+"resource:basis/bootstrap/primitives.factor" run-file
+
+load-help? off
+{ "resource:core" } vocab-roots set
+
+! Create a boot quotation for the target by collecting all top-level
+! forms into a quotation, surrounded by some boilerplate.
+[
+    [
+        ! Rehash hashtables first, since bootstrap.image creates
+        ! them using the host image's hashing algorithms.
+        [ hashtable? ] instances [ hashtables:rehash ] each
+        [ hash-set? ] instances [ hash-sets:rehash ] each
+        boot
+    ] %
+
+    "math.integers" require
+    "math.ratios" require
+    "math.floats" require
+    "memory" require
+
+    "io.streams.c" require
+    "io.streams.byte-array" require ! for utf16 on Windows
+    "vocabs.loader" require
+
+    "syntax" require
+
+    "locals" require
+    "locals.fry" require
+    "locals.macros" require
+
+    "resource:basis/bootstrap/layouts.factor" parse-file %
+
+    [
+        f parser-quiet? set-global
+
+        init-resource-path
+
+        "resource:basis/bootstrap/stage2.factor"
+        dup file-exists? [
+            run-file
+        ] [
+            "Cannot find " write write "." print
+            "Please move " write image-path write " into the same directory as the Factor sources," print
+            "and try again." print
+            1 (exit)
+        ] if
+    ] %
+] [ ] make
+OBJ-STARTUP-QUOT
+bootstrap.image.private:special-objects get set-at
index db8f335eea66616296a04e8a8849f32cdc97f2fe..3e6e58a8bb6eb1dd7df76162b80a92795e031acf 100644 (file)
@@ -95,9 +95,9 @@ CONSTANT: default-components
     print-report
 
     "staging" get [
-        "vocab:bootstrap/finish-staging.factor" run-file
+        "resource:basis/bootstrap/finish-staging.factor" run-file
     ] [
-        "vocab:bootstrap/finish-bootstrap.factor" run-file
+        "resource:basis/bootstrap/finish-bootstrap.factor" run-file
     ] if
 
     f error set-global
@@ -108,7 +108,7 @@ CONSTANT: default-components
     drop
     [
         load-help? off
-        [ "vocab:bootstrap/bootstrap-error.factor" parse-file ] save/restore-error
+        [ "resource:basis/bootstrap/bootstrap-error.factor" parse-file ] save/restore-error
         call
     ] with-scope
 ] recover
diff --git a/basis/bootstrap/summary.txt b/basis/bootstrap/summary.txt
new file mode 100644 (file)
index 0000000..208332e
--- /dev/null
@@ -0,0 +1 @@
+Bootstrap image generation
diff --git a/basis/bootstrap/syntax.factor b/basis/bootstrap/syntax.factor
new file mode 100644 (file)
index 0000000..302bf7a
--- /dev/null
@@ -0,0 +1,120 @@
+! Copyright (C) 2007, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: words words.symbol sequences vocabs kernel
+compiler.units ;
+IN: bootstrap.syntax
+
+[
+    "syntax" create-vocab drop
+
+    {
+        "\""
+        "("
+        ":"
+        ";"
+        "<PRIVATE"
+        "B{"
+        "BV{"
+        "C:"
+        "CHAR:"
+        "DEFER:"
+        "ERROR:"
+        "FORGET:"
+        "GENERIC#:"
+        "GENERIC:"
+        "HOOK:"
+        "H{"
+        "HS{"
+        "IH{"
+        "IN:"
+        "INSTANCE:"
+        "M:"
+        "MAIN:"
+        "MATH:"
+        "MIXIN:"
+        "NAN:"
+        "P\""
+        "POSTPONE:"
+        "PREDICATE:"
+        "PRIMITIVE:"
+        "PRIVATE>"
+        "SBUF\""
+        "SINGLETON:"
+        "SINGLETONS:"
+        "BUILTIN:"
+        "SYMBOL:"
+        "SYMBOLS:"
+        "CONSTANT:"
+        "TUPLE:"
+        "final"
+        "SLOT:"
+        "T{"
+        "UNION:"
+        "INTERSECTION:"
+        "REUSE:"
+        "USE:"
+        "UNUSE:"
+        "USING:"
+        "QUALIFIED:"
+        "QUALIFIED-WITH:"
+        "FROM:"
+        "EXCLUDE:"
+        "RENAME:"
+        "ALIAS:"
+        "SYNTAX:"
+        "V{"
+        "W{"
+        "["
+        "\\"
+        "M\\"
+        "]"
+        "auto-use"
+        "delimiter"
+        "deprecated"
+        "f"
+        "flushable"
+        "foldable"
+        "inline"
+        "recursive"
+        "t"
+        "{"
+        "}"
+        "CS{"
+        "<<"
+        ">>"
+        "call-next-method"
+        "not{"
+        "maybe{"
+        "union{"
+        "intersection{"
+        "initial:"
+        "read-only"
+        "call("
+        "execute("
+        "<<<<<<"
+        "======"
+        ">>>>>>"
+        "<<<<<<<"
+        "======="
+        ">>>>>>>"
+        "'["
+        "'{"
+        "'H{"
+        "'HS{"
+        "_"
+        "@"
+        "MACRO:"
+        "MEMO:"
+        "IDENTITY-MEMO:"
+        ":>"
+        "[|"
+        "[let"
+        "::"
+        "M::"
+        "MACRO::"
+        "MEMO::"
+        "IDENTITY-MEMO::"
+    } [ "syntax" create-word drop ] each
+
+    "t" "syntax" lookup-word define-symbol
+] with-compilation-unit
diff --git a/core/bootstrap/layouts.factor b/core/bootstrap/layouts.factor
deleted file mode 100644 (file)
index 6ff54d4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays byte-arrays kernel layouts math namespaces
-quotations strings words ;
-
-16 data-alignment set
-
-0b1111 tag-mask set
-4 tag-bits set
-
-32 mega-cache-size set
-
-! Type tags, should be kept in sync with:
-!   vm/layouts.hpp
-H{
-    { fixnum 0 }
-    { POSTPONE: f 1 }
-    { array 2 }
-    { float 3 }
-    { quotation 4 }
-    { bignum 5 }
-    { alien 6 }
-    { tuple 7 }
-    { wrapper 8 }
-    { byte-array 9 }
-    { callstack 10 }
-    { string 11 }
-    { word 12 }
-    { dll 13 }
-} type-numbers set
-
-14 num-types set
-
-2 header-bits set
diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor
deleted file mode 100644 (file)
index 3707a11..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-! Copyright (C) 2004, 2010 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays assocs bootstrap.image.primitives
-bootstrap.image.private classes classes.builtin classes.intersection
-classes.predicate classes.private classes.singleton classes.tuple
-classes.tuple.private classes.union combinators compiler.units io
-kernel kernel.private layouts make math math.private namespaces parser
-quotations sequences slots source-files splitting vocabs vocabs.loader
-words ;
-IN: bootstrap.primitives
-
-"* Creating primitives and basic runtime structures..." print flush
-
-H{ } clone sub-primitives set
-
-"vocab:bootstrap/syntax.factor" parse-file
-
-: asm-file ( arch -- file )
-    "-" split reverse "." join
-    "vocab:bootstrap/assembler/" ".factor" surround ;
-
-architecture get asm-file parse-file
-
-"vocab:bootstrap/layouts.factor" parse-file
-
-! Now we have ( syntax-quot arch-quot layouts-quot ) on the stack
-
-! Bring up a bare cross-compiling vocabulary.
-"syntax" lookup-vocab vocab-words-assoc bootstrap-syntax set
-
-H{ } clone dictionary set
-H{ } clone root-cache set
-H{ } clone source-files set
-H{ } clone update-map set
-H{ } clone implementors-map set
-
-init-caches
-
-bootstrapping? on
-
-call( -- ) ! layouts quot
-call( -- ) ! arch quot
-
-! Vocabulary for slot accessors
-"accessors" create-vocab drop
-
-! After we execute bootstrap/layouts
-num-types get f <array> builtins set
-
-[
-
-call( -- ) ! syntax-quot
-
-! create-word some empty vocabs where the below primitives and
-! classes will go
-{
-    "alien"
-    "alien.accessors"
-    "alien.libraries"
-    "alien.private"
-    "arrays"
-    "byte-arrays"
-    "classes.private"
-    "classes.tuple"
-    "classes.tuple.private"
-    "classes.predicate"
-    "compiler.units"
-    "continuations.private"
-    "generic.single"
-    "generic.single.private"
-    "growable"
-    "hashtables"
-    "hashtables.private"
-    "io"
-    "io.files"
-    "io.files.private"
-    "io.streams.c"
-    "locals.backend"
-    "kernel"
-    "kernel.private"
-    "math"
-    "math.parser.private"
-    "math.private"
-    "memory"
-    "memory.private"
-    "quotations"
-    "quotations.private"
-    "sbufs"
-    "sbufs.private"
-    "scratchpad"
-    "sequences"
-    "sequences.private"
-    "slots.private"
-    "strings"
-    "strings.private"
-    "system"
-    "system.private"
-    "threads.private"
-    "tools.dispatch.private"
-    "tools.memory.private"
-    "tools.profiler.sampling.private"
-    "words"
-    "words.private"
-    "vectors"
-    "vectors.private"
-    "vm"
-} [ create-vocab drop ] each
-
-! Builtin classes
-: lookup-type-number ( word -- n )
-    [ target-word ] with-global type-number ;
-
-: register-builtin ( class -- )
-    [ dup lookup-type-number "type" set-word-prop ]
-    [ dup "type" word-prop builtins get set-nth ]
-    [ f f f builtin-class define-class ]
-    tri ;
-
-: prepare-slots ( slots -- slots' )
-    [ [ dup pair? [ first2 create-word ] when ] map ] map ;
-
-: define-builtin-slots ( class slots -- )
-    prepare-slots make-slots 1 finalize-slots
-    [ "slots" set-word-prop ] [ define-accessors ] 2bi ;
-
-: define-builtin-predicate ( class -- )
-    dup class>type [ eq? ] curry [ tag ] prepend define-predicate ;
-
-: define-builtin ( symbol slotspec -- )
-    [ [ define-builtin-predicate ] keep ] dip define-builtin-slots ;
-
-{
-    { "alien" "alien" }
-    { "array" "arrays" }
-    { "bignum" "math" }
-    { "byte-array" "byte-arrays" }
-    { "callstack" "kernel" }
-    { "dll" "alien" }
-    { "fixnum" "math" }
-    { "float" "math" }
-    { "quotation" "quotations" }
-    { "string" "strings" }
-    { "tuple" "kernel" }
-    { "word" "words" }
-    { "wrapper" "kernel" }
-} [ create-word register-builtin ] assoc-each
-
-"f" "syntax" lookup-word register-builtin
-
-! We need this before defining c-ptr below
-"f" "syntax" lookup-word { } define-builtin
-
-"f" "syntax" create-word [ not ] "predicate" set-word-prop
-"f?" "syntax" vocab-words-assoc delete-at
-
-"t" "syntax" lookup-word define-singleton-class
-
-! Some unions
-"c-ptr" "alien" create-word [
-    "alien" "alien" lookup-word ,
-    "f" "syntax" lookup-word ,
-    "byte-array" "byte-arrays" lookup-word ,
-] { } make define-union-class
-
-"integer" "math" create-word
-"fixnum" "math" lookup-word "bignum" "math" lookup-word 2array
-define-union-class
-
-! Two predicate classes used for declarations.
-"array-capacity" "sequences.private" create-word
-"fixnum" "math" lookup-word
-[
-    [ dup 0 fixnum>= ] %
-    bootstrap-max-array-capacity <fake-bignum> [ fixnum<= ] curry ,
-    [ [ drop f ] if ] %
-] [ ] make
-define-predicate-class
-
-"array-capacity" "sequences.private" lookup-word
-[ >fixnum ] bootstrap-max-array-capacity <fake-bignum> [ fixnum-bitand ] curry append
-"coercer" set-word-prop
-
-"integer-array-capacity" "sequences.private" create-word
-"integer" "math" lookup-word
-[
-    [ dup 0 >= ] %
-    bootstrap-max-array-capacity <fake-bignum> [ <= ] curry ,
-    [ [ drop f ] if ] %
-] [ ] make
-define-predicate-class
-
-! Catch-all class for providing a default method.
-"object" "kernel" create-word
-[ f f { } intersection-class define-class ]
-[ [ drop t ] "predicate" set-word-prop ]
-bi
-
-"object?" "kernel" vocab-words-assoc delete-at
-
-! Empty class with no instances
-"null" "kernel" create-word
-[ f { } f union-class define-class ]
-[ [ drop f ] "predicate" set-word-prop ]
-bi
-
-"null?" "kernel" vocab-words-assoc delete-at
-
-"fixnum" "math" create-word { } define-builtin
-"fixnum" "math" create-word "integer>fixnum-strict" "math" create-word 1quotation "coercer" set-word-prop
-
-"bignum" "math" create-word { } define-builtin
-"bignum" "math" create-word ">bignum" "math" create-word 1quotation "coercer" set-word-prop
-
-"float" "math" create-word { } define-builtin
-"float" "math" create-word ">float" "math" create-word 1quotation "coercer" set-word-prop
-
-"array" "arrays" create-word {
-    { "length" { "array-capacity" "sequences.private" } read-only }
-} define-builtin
-
-"wrapper" "kernel" create-word {
-    { "wrapped" read-only }
-} define-builtin
-
-"string" "strings" create-word {
-    { "length" { "array-capacity" "sequences.private" } read-only }
-    "aux"
-} define-builtin
-
-"quotation" "quotations" create-word {
-    { "array" { "array" "arrays" } read-only }
-    "cached-effect"
-    "cache-counter"
-} define-builtin
-
-"dll" "alien" create-word {
-    { "path" { "byte-array" "byte-arrays" } read-only }
-} define-builtin
-
-"alien" "alien" create-word {
-    { "underlying" { "c-ptr" "alien" } read-only }
-    "expired"
-} define-builtin
-
-"word" "words" create-word {
-    { "hashcode" { "fixnum" "math" } }
-    "name"
-    "vocabulary"
-    { "def" { "quotation" "quotations" } initial: [ ] }
-    "props"
-    "pic-def"
-    "pic-tail-def"
-    { "sub-primitive" read-only }
-} define-builtin
-
-"byte-array" "byte-arrays" create-word {
-    { "length" { "array-capacity" "sequences.private" } read-only }
-} define-builtin
-
-"callstack" "kernel" create-word { } define-builtin
-
-"tuple" "kernel" create-word
-[ { } define-builtin ]
-[ define-tuple-layout ]
-bi
-
-! create-word special tombstone values
-"tombstone" "hashtables.private" create-word
-tuple
-{ "state" } define-tuple-class
-
-"+empty+" "hashtables.private" create-word
-{ f } "tombstone" "hashtables.private" lookup-word
-slots>tuple 1quotation ( -- value ) define-inline
-
-"+tombstone+" "hashtables.private" create-word
-{ t } "tombstone" "hashtables.private" lookup-word
-slots>tuple 1quotation ( -- value ) define-inline
-
-! Some tuple classes
-
-"curried" "kernel" create-word
-tuple
-{
-    { "obj" read-only }
-    { "quot" read-only }
-} prepare-slots define-tuple-class
-
-"curry" "kernel" create-word
-{
-    [ f "inline" set-word-prop ]
-    [ make-flushable ]
-} cleave
-
-"curry" "kernel" lookup-word
-[
-    callable instance-check-quot %
-    "curried" "kernel" lookup-word tuple-layout ,
-    \ <tuple-boa> ,
-] [ ] make
-( obj quot -- curry ) define-declared
-
-"composed" "kernel" create-word
-tuple
-{
-    { "first" read-only }
-    { "second" read-only }
-} prepare-slots define-tuple-class
-
-"compose" "kernel" create-word
-{
-    [ f "inline" set-word-prop ]
-    [ make-flushable ]
-} cleave
-
-"compose" "kernel" lookup-word
-[
-    callable instance-check-quot [ dip ] curry %
-    callable instance-check-quot %
-    "composed" "kernel" lookup-word tuple-layout ,
-    \ <tuple-boa> ,
-] [ ] make
-( quot1 quot2 -- compose ) define-declared
-
-"* Declaring primitives..." print flush
-all-primitives create-primitives
-
-! Bump build number
-"build" "kernel" create-word build 1 + [ ] curry ( -- n ) define-declared
-
-] with-compilation-unit
diff --git a/core/bootstrap/stage1.factor b/core/bootstrap/stage1.factor
deleted file mode 100644 (file)
index 54fef16..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-! Copyright (C) 2004, 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: assocs bootstrap.image.private hash-sets hashtables init
-io io.files kernel kernel.private make memory namespaces parser
-parser.notes sequences system vocabs vocabs.loader ;
-
-"Bootstrap stage 1..." print flush
-
-"vocab:bootstrap/primitives.factor" run-file
-
-load-help? off
-{ "resource:core" } vocab-roots set
-
-! Create a boot quotation for the target by collecting all top-level
-! forms into a quotation, surrounded by some boilerplate.
-[
-    [
-        ! Rehash hashtables first, since bootstrap.image creates
-        ! them using the host image's hashing algorithms.
-        [ hashtable? ] instances [ hashtables:rehash ] each
-        [ hash-set? ] instances [ hash-sets:rehash ] each
-        boot
-    ] %
-
-    "math.integers" require
-    "math.ratios" require
-    "math.floats" require
-    "memory" require
-
-    "io.streams.c" require
-    "io.streams.byte-array" require ! for utf16 on Windows
-    "vocabs.loader" require
-
-    "syntax" require
-
-    "locals" require
-    "locals.fry" require
-    "locals.macros" require
-
-    "vocab:bootstrap/layouts.factor" parse-file %
-
-    [
-        f parser-quiet? set-global
-
-        init-resource-path
-
-        "resource:basis/bootstrap/stage2.factor"
-        dup file-exists? [
-            run-file
-        ] [
-            "Cannot find " write write "." print
-            "Please move " write image-path write " into the same directory as the Factor sources," print
-            "and try again." print
-            1 (exit)
-        ] if
-    ] %
-] [ ] make
-OBJ-STARTUP-QUOT
-bootstrap.image.private:special-objects get set-at
diff --git a/core/bootstrap/summary.txt b/core/bootstrap/summary.txt
deleted file mode 100644 (file)
index 208332e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Bootstrap image generation
diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor
deleted file mode 100644 (file)
index 302bf7a..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-! Copyright (C) 2007, 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: words words.symbol sequences vocabs kernel
-compiler.units ;
-IN: bootstrap.syntax
-
-[
-    "syntax" create-vocab drop
-
-    {
-        "\""
-        "("
-        ":"
-        ";"
-        "<PRIVATE"
-        "B{"
-        "BV{"
-        "C:"
-        "CHAR:"
-        "DEFER:"
-        "ERROR:"
-        "FORGET:"
-        "GENERIC#:"
-        "GENERIC:"
-        "HOOK:"
-        "H{"
-        "HS{"
-        "IH{"
-        "IN:"
-        "INSTANCE:"
-        "M:"
-        "MAIN:"
-        "MATH:"
-        "MIXIN:"
-        "NAN:"
-        "P\""
-        "POSTPONE:"
-        "PREDICATE:"
-        "PRIMITIVE:"
-        "PRIVATE>"
-        "SBUF\""
-        "SINGLETON:"
-        "SINGLETONS:"
-        "BUILTIN:"
-        "SYMBOL:"
-        "SYMBOLS:"
-        "CONSTANT:"
-        "TUPLE:"
-        "final"
-        "SLOT:"
-        "T{"
-        "UNION:"
-        "INTERSECTION:"
-        "REUSE:"
-        "USE:"
-        "UNUSE:"
-        "USING:"
-        "QUALIFIED:"
-        "QUALIFIED-WITH:"
-        "FROM:"
-        "EXCLUDE:"
-        "RENAME:"
-        "ALIAS:"
-        "SYNTAX:"
-        "V{"
-        "W{"
-        "["
-        "\\"
-        "M\\"
-        "]"
-        "auto-use"
-        "delimiter"
-        "deprecated"
-        "f"
-        "flushable"
-        "foldable"
-        "inline"
-        "recursive"
-        "t"
-        "{"
-        "}"
-        "CS{"
-        "<<"
-        ">>"
-        "call-next-method"
-        "not{"
-        "maybe{"
-        "union{"
-        "intersection{"
-        "initial:"
-        "read-only"
-        "call("
-        "execute("
-        "<<<<<<"
-        "======"
-        ">>>>>>"
-        "<<<<<<<"
-        "======="
-        ">>>>>>>"
-        "'["
-        "'{"
-        "'H{"
-        "'HS{"
-        "_"
-        "@"
-        "MACRO:"
-        "MEMO:"
-        "IDENTITY-MEMO:"
-        ":>"
-        "[|"
-        "[let"
-        "::"
-        "M::"
-        "MACRO::"
-        "MEMO::"
-        "IDENTITY-MEMO::"
-    } [ "syntax" create-word drop ] each
-
-    "t" "syntax" lookup-word define-symbol
-] with-compilation-unit