File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ objs = \
2020 string.o \
2121 io.o \
2222 error.o \
23+ os.o \
2324 stdlib.o
2425
2526default : runtime.o
Original file line number Diff line number Diff line change 1818
1919;; Label -> String
2020(define label-symbol->string
21- (match (system-type 'os )
21+ (match (system-type)
2222 ['macosx
2323 (λ (s) (string-append "_ " (symbol->string s)))]
2424 [_ symbol->string]))
2525
2626;; Label -> String
2727;; prefix with _ for Mac
2828(define label-symbol->string/rel
29- (match (system-type 'os )
29+ (match (system-type)
3030 ['macosx
3131 (λ (s) (string-append "_ " (symbol->string s)))]
3232 [_
7676(define (external-label-shared? x)
7777 (and (label? x)
7878 (current-shared?)
79- (eq? 'unix (system-type 'os ))
79+ (eq? 'unix (system-type))
8080 (memq x (unbox external-labels))))
8181
8282(define (mov->string a1 a2)
Original file line number Diff line number Diff line change 1212 (unpad-stack))]
1313 ['current-input-port ; hack, doesn't actually exist
1414 (seq (Mov rax val-void))]
15+ ['system-type
16+ (seq (pad-stack)
17+ (Call 'system_type )
18+ (Sal rax int-shift)
19+ (unpad-stack))]
1520
1621 ;; Op1
1722 ['add1
Original file line number Diff line number Diff line change 102102 open_input_file
103103 read_byte_port
104104 peek_byte_port
105- is_char_alphabetic)))
105+ is_char_alphabetic
106+ system_type)))
106107
107108(define cons-function
108109 (let ((code (gensym 'cons_code ))
Original file line number Diff line number Diff line change 322322(define op0
323323 '(read-byte void read-char peek-char
324324 current-input-port ; hack, doesn't actually exist
325+ system-type
325326 ))
326327
327328(define op1
Original file line number Diff line number Diff line change 99 remove-duplicates remq* remove* remove
1010 andmap vector list->vector boolean? substring
1111 odd?
12- system-type ;; hard-coded
12+ system-type
1313 not
1414 findf
1515 read-line
299299(define (odd? x)
300300 (= (remainder x 2 ) 1 ))
301301
302- ;; FIXME: hard-coded system type
303- (define (system-type _ )
304- 'unix )
305- ; 'macosx)
302+ (define (system-type)
303+ ;; the primitive system type returns 1 for mac, 0 otherwise;
304+ ;; the fall through case is for when %system-type is implemented in Racket
305+ (match (%system-type)
306+ [1 'macosx ]
307+ [0 'unix ]
308+ [x x]))
306309
307310(define (not x)
308311 (if x #f #t ))
Original file line number Diff line number Diff line change 601601 (check-equal? (run '(let ((x 1 )) x x)) 1 )
602602 (check-equal? (run '(let ((x 1 )) x x x)) 1 )
603603 (check-equal? (run '(match 1 [1 2 3 ])) 3 )
604+ (check-equal? (run '(system-type)) (system-type))
604605 )
605606
606607
You can’t perform that action at this time.
0 commit comments