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
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
: 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
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
: 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
: 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
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
: 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
! 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
: 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
: 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
{ 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 ;
{ $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." ;
--- /dev/null
+! 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
--- /dev/null
+! 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
--- /dev/null
+! 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
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
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
--- /dev/null
+Bootstrap image generation
--- /dev/null
+! 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
+++ /dev/null
-! 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
+++ /dev/null
-! 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
+++ /dev/null
-! 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
+++ /dev/null
-Bootstrap image generation
+++ /dev/null
-! 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