]> gitweb.factorcode.org Git - factor.git/blob - basis/bootstrap/stage2.factor
Remove cruddy string encoding/decoding code from VM
[factor.git] / basis / bootstrap / stage2.factor
1 ! Copyright (C) 2004, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors init namespaces words words.symbol io
4 kernel.private math memory continuations kernel io.files
5 io.pathnames io.backend system parser vocabs sequences
6 vocabs.loader combinators splitting source-files strings
7 definitions assocs compiler.units math.parser
8 generic sets command-line ;
9 IN: bootstrap.stage2
10
11 SYMBOL: core-bootstrap-time
12
13 SYMBOL: bootstrap-time
14
15 : default-image-name ( -- string )
16     vm file-name os windows? [ "." split1-last drop ] when
17     ".image" append resource-path ;
18
19 : load-components ( -- )
20     "include" "exclude"
21     [ get-global " " split harvest ] bi@
22     diff
23     [ "bootstrap." prepend require ] each ;
24
25 : count-words ( pred -- )
26     all-words swap count number>string write ; inline
27
28 : print-time ( ms -- )
29     1000 /i
30     60 /mod swap
31     number>string write
32     " minutes and " write number>string write " seconds." print ;
33
34 : print-report ( -- )
35     "Core bootstrap completed in " write core-bootstrap-time get print-time
36     "Bootstrap completed in "      write bootstrap-time      get print-time
37
38     "Bootstrapping is complete." print
39     "Now, you can run Factor:" print
40     vm write " -i=" write "output-image" get print flush ;
41
42 : save/restore-error ( quot -- )
43     error get-global
44     error-continuation get-global
45     [ call ] 2dip
46     error-continuation set-global
47     error set-global ; inline
48
49 [
50     ! We time bootstrap
51     millis
52
53     default-image-name "output-image" set-global
54
55     "math compiler threads help io tools ui ui.tools unicode handbook" "include" set-global
56     "" "exclude" set-global
57
58     (command-line) parse-command-line
59
60     ! Set dll paths
61     os wince? [ "windows.ce" require ] when
62     os winnt? [ "windows.nt" require ] when
63
64     "staging" get "deploy-vocab" get or [
65         "stage2: deployment mode" print
66     ] [
67         "debugger" require
68         "inspector" require
69         "tools.errors" require
70         "listener" require
71         "none" require
72     ] if
73
74     load-components
75
76     millis over - core-bootstrap-time set-global
77
78     run-bootstrap-init
79
80     f error set-global
81     f error-continuation set-global
82
83     millis swap - bootstrap-time set-global
84     print-report
85
86     "deploy-vocab" get [
87         "tools.deploy.shaker" run
88     ] [
89         "staging" get [
90             "vocab:bootstrap/finish-staging.factor" run-file
91         ] [
92             "vocab:bootstrap/finish-bootstrap.factor" run-file
93         ] if
94
95         "output-image" get save-image-and-exit
96     ] if
97 ] [
98     drop
99     [
100         load-help? off
101         [ "vocab:bootstrap/bootstrap-error.factor" parse-file ] save/restore-error
102         call
103     ] with-scope
104 ] recover