]> gitweb.factorcode.org Git - factor.git/blob - library/cross-compiler.factor
4113a6087876aef91063ea841268fb4bfbd47259
[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: namespaces
33 USE: parser
34 USE: real-math
35 USE: stack
36 USE: stdio
37 USE: streams
38 USE: strings
39 USE: vectors
40 USE: vectors
41 USE: vocabularies
42 USE: words
43
44 IN: arithmetic
45 DEFER: number=
46 DEFER: >integer
47 DEFER: /i
48
49 IN: kernel
50 DEFER: getenv
51 DEFER: setenv
52 DEFER: save-image
53 DEFER: room
54 DEFER: os-env
55 DEFER: type-of
56 DEFER: size-of
57
58 IN: strings
59 DEFER: str=
60 DEFER: str-hashcode
61 DEFER: sbuf=
62 DEFER: clone-sbuf
63
64 IN: io-internals
65 DEFER: port?
66 DEFER: open-file
67 DEFER: server-socket
68 DEFER: close-fd
69 DEFER: accept-fd
70 DEFER: read-line-fd-8
71 DEFER: write-fd-8
72 DEFER: flush-fd
73
74 IN: parser
75 DEFER: str>float
76
77 IN: random
78 DEFER: init-random
79 DEFER: (random-int)
80
81 IN: words
82 DEFER: <word>
83 DEFER: word-primitive
84 DEFER: set-word-primitive
85 DEFER: word-parameter
86 DEFER: set-word-parameter
87 DEFER: word-plist
88 DEFER: set-word-plist
89
90 IN: unparser
91 DEFER: unparse-float
92
93 IN: cross-compiler
94
95 : primitives, ( -- )
96     1 [
97         execute
98         call
99         ifte
100         cons?
101         cons
102         car
103         cdr
104         set-car
105         set-cdr
106         vector?
107         <vector>
108         vector-length
109         set-vector-length
110         vector-nth
111         set-vector-nth
112         string?
113         str-length
114         str-nth
115         str-compare
116         str=
117         str-hashcode
118         index-of*
119         substring
120         sbuf?
121         <sbuf>
122         sbuf-length
123         set-sbuf-length
124         sbuf-nth
125         set-sbuf-nth
126         sbuf-append
127         sbuf>str
128         clone-sbuf
129         sbuf=
130         number?
131         >fixnum
132         >bignum
133         >integer
134         >float
135         number=
136         fixnum?
137         bignum?
138         ratio?
139         numerator
140         denominator
141         float?
142         str>float
143         unparse-float
144         float>bits
145         complex?
146         real
147         imaginary
148         >rect
149         rect>
150         +
151         -
152         *
153         /i
154         /f
155         /
156         mod
157         /mod
158         bitand
159         bitor
160         bitxor
161         bitnot
162         shift<
163         shift>
164         <
165         <=
166         >
167         >=
168         gcd
169         facos
170         fasin
171         fatan
172         fatan2
173         fcos
174         fexp
175         fcosh
176         flog
177         fpow
178         fsin
179         fsinh
180         fsqrt
181         word?
182         <word>
183         word-primitive
184         set-word-primitive
185         word-parameter
186         set-word-parameter
187         word-plist
188         set-word-plist
189         drop
190         dup
191         swap
192         over
193         pick
194         nip
195         tuck
196         rot
197         >r
198         r>
199         eq?
200         getenv
201         setenv
202         open-file
203         garbage-collection
204         save-image
205         datastack
206         callstack
207         set-datastack
208         set-callstack
209         port?
210         exit*
211         server-socket
212         close-fd
213         accept-fd
214         read-line-fd-8
215         write-fd-8
216         flush-fd
217         room
218         os-env
219         millis
220         init-random
221         (random-int)
222         type-of
223         size-of
224     ] [
225         swap succ tuck primitive,
226     ] each drop ;
227
228 : version, ( -- )
229     "version" [ "kernel" ] search version unit compound, ;
230
231 : make-image ( name -- )
232     #! Make an image for the C interpreter.
233     [
234         "/library/platform/native/boot.factor" run-resource
235     ] with-image
236
237     swap write-image ;
238
239 : make-images ( -- )
240     "big-endian" off "factor.image.le" make-image
241     "big-endian" on  "factor.image.be" make-image ;