]> gitweb.factorcode.org Git - factor.git/blob - library/cross-compiler.factor
bbe6582448056fe9ebcf98a1fc8e9a548c997110
[factor.git] / library / cross-compiler.factor
1 ! :folding=none:collapseFolds=1:
2
3 ! $Id$
4 !
5 ! Copyright (C) 2004 Slava Pestov.
6
7 ! Redistribution and use in source and binary forms, with or without
8 ! modification, are permitted provided that the following conditions are met:
9
10 ! 1. Redistributions of source code must retain the above copyright notice,
11 !    this list of conditions and the following disclaimer.
12
13 ! 2. Redistributions in binary form must reproduce the above copyright notice,
14 !    this list of conditions and the following disclaimer in the documentation
15 !    and/or other materials provided with the distribution.
16
17 ! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 ! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 ! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 ! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 ! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 ! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 ! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 ! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 IN: cross-compiler
29 USE: arithmetic
30 USE: kernel
31 USE: lists
32 USE: parser
33 USE: stack
34 USE: stdio
35 USE: streams
36 USE: strings
37 USE: vectors
38 USE: vectors
39 USE: vocabularies
40 USE: words
41
42 IN: arithmetic
43 DEFER: number=
44 DEFER: >integer
45 DEFER: /i
46
47 IN: kernel
48 DEFER: getenv
49 DEFER: setenv
50 DEFER: save-image
51 DEFER: handle?
52 DEFER: room
53 DEFER: os-env
54
55 IN: strings
56 DEFER: str=
57 DEFER: str-hashcode
58
59 IN: io-internals
60 DEFER: open-file
61 DEFER: server-socket
62 DEFER: close-fd
63 DEFER: accept-fd
64 DEFER: read-line-fd-8
65 DEFER: write-fd-8
66 DEFER: flush-fd
67 DEFER: shutdown-fd
68
69 IN: parser
70 DEFER: str>float
71
72 IN: random
73 DEFER: init-random
74 DEFER: (random-int)
75
76 IN: words
77 DEFER: <word>
78 DEFER: word-primitive
79 DEFER: set-word-primitive
80 DEFER: word-parameter
81 DEFER: set-word-parameter
82 DEFER: word-plist
83 DEFER: set-word-plist
84
85 IN: unparser
86 DEFER: unparse-float
87
88 IN: cross-compiler
89
90 : primitives, ( -- )
91     1 [
92         execute
93         call
94         ifte
95         cons?
96         cons
97         car
98         cdr
99         set-car
100         set-cdr
101         vector?
102         <vector>
103         vector-length
104         set-vector-length
105         vector-nth
106         set-vector-nth
107         string?
108         str-length
109         str-nth
110         str-compare
111         str=
112         str-hashcode
113         index-of*
114         substring
115         sbuf?
116         <sbuf>
117         sbuf-length
118         set-sbuf-length
119         sbuf-nth
120         set-sbuf-nth
121         sbuf-append
122         sbuf>str
123         number?
124         >fixnum
125         >bignum
126         >integer
127         >float
128         number=
129         fixnum?
130         bignum?
131         ratio?
132         numerator
133         denominator
134         float?
135         str>float
136         unparse-float
137         +
138         -
139         *
140         /i
141         /f
142         /
143         mod
144         /mod
145         bitand
146         bitor
147         bitxor
148         bitnot
149         shift<
150         shift>
151         <
152         <=
153         >
154         >=
155         word?
156         <word>
157         word-primitive
158         set-word-primitive
159         word-parameter
160         set-word-parameter
161         word-plist
162         set-word-plist
163         drop
164         dup
165         swap
166         over
167         pick
168         nip
169         tuck
170         rot
171         >r
172         r>
173         eq?
174         getenv
175         setenv
176         open-file
177         garbage-collection
178         save-image
179         datastack
180         callstack
181         set-datastack
182         set-callstack
183         handle?
184         exit*
185         server-socket
186         close-fd
187         accept-fd
188         read-line-fd-8
189         write-fd-8
190         flush-fd
191         shutdown-fd
192         room
193         os-env
194         millis
195         init-random
196         (random-int)
197     ] [
198         swap succ tuck primitive,
199     ] each drop ;
200
201 : version, ( -- )
202     "version" [ "kernel" ] search version unit compound, ;
203
204 : make-image ( -- )
205     #! Make an image for the C interpreter.
206     [
207         "/library/platform/native/boot.factor" run-resource
208     ] with-image
209
210     ! Uncomment this on sparc and powerpc.
211     ! "big-endian" on
212     "factor.image" write-image ;