Skip to content
This repository has been archived by the owner on Jan 28, 2018. It is now read-only.

Commit

Permalink
HOST: set
Browse files Browse the repository at this point in the history
  • Loading branch information
zaoqi committed Dec 30, 2017
1 parent b71299e commit 2d09407
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions prelude.scm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

(define raise
(HOSTz
[r7rs raise]
[(r7rs r6rs r5rs scheme) raise]
[map (^lambda (x) (^return (^raise x)))]))
(define CATCHz
(HOSTz
Expand All @@ -113,23 +113,23 @@
[_ VOIDz])
(define CARz
(HOSTz
[r7rs car]
[(r7rs r6rs r5rs scheme) car]
[map
(^lambda (p)
(^if-boolean/do (ISPAIRz p)
[(^return (CARPz p))]
[(^return (^vector-head p))]))]))
(define CDRz
(HOSTz
[r7rs cdr]
[(r7rs r6rs r5rs scheme) cdr]
[map
(^lambda (p)
(^if-boolean/do (ISPAIRz p)
[(^return (CDRPz p))]
[(^return (^vector-tail p))]))]))
(define pair?
(HOSTz
[r7rs pair?]
[(r7rs r6rs r5rs scheme) pair?]
[map (^lambda (x) (^return (^or (^vector? x) (ISPAIRz x))))]))
(define (car p)
(if (pair? p)
Expand All @@ -141,11 +141,11 @@
(error "cdr: isn't a pair:" p)))
(define list?
(HOSTz
[r7rs list?]
[(r7rs r6rs r5rs scheme) list?]
[map (^lambda (x) (^return (^vector? x)))]))
(define cons
(HOSTz
[r7rs cons]
[(r7rs r6rs r5rs scheme) cons]
[map (^lambda (a d)
(^if-boolean/do (^vector? d)
[(^return (^vector-append (^vector a) d))]
Expand Down
9 changes: 5 additions & 4 deletions z.scm
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@
(k state modules ($$lambda (set->list (set-subtract vars (args->set args) defines1)) (set->list defines1) args cs)))))
(define (HOST xs k1 k2)
(let ([x (car xs)] [xs (cdr xs)])
(cond
[(eq? (first x) $host) (k1 (second x))]
[(eq? (first x) '_) (k2 (second x))]
[else (HOST xs k1 k2)])))
(let ([arch (first x)] [code (second x)])
(cond
[(or (eq? arch $host) (and (pair? arch) (member $host arch))) (k1 code)]
[(eq? (first x) '_) (k2 code)]
[else (HOST xs k1 k2)]))))

(define prelude (file->list "prelude.scm"))
(define preludeC
Expand Down

0 comments on commit 2d09407

Please sign in to comment.