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

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zaoqi committed Dec 31, 2017
1 parent 2d09407 commit 43b010c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Map
Submodule Map updated from 2f45ca to fcd168
4 changes: 2 additions & 2 deletions map.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.

(load "z.scm")

(define ($$tail-if b xs ys) (list (**if b xs ys)))
(define $if *if)
(define $void *undefined)
Expand Down Expand Up @@ -129,3 +127,5 @@
; (define >=UZ (lambda (x y) (return (>= x y))))
; )))
;(define (+prelude x) (string-append prelude";"x))

(load "z.scm")
2 changes: 1 addition & 1 deletion prelude.scm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
(define raise
(HOSTz
[(r7rs r6rs r5rs scheme) raise]
[map (^lambda (x) (^return (^raise x)))]))
[map (^lambda (x) (^raise x))]))
(define CATCHz
(HOSTz
[r7rs
Expand Down
23 changes: 12 additions & 11 deletions z.scm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
module?
(export-macros module-export-macros)
(export-values module-export-values))
(define (MODULE/k state name modules macros defines dir exports body k) ; (k state defines modules xs)
(define (MODULE/k state name modules macros defines dir exports body k) ; (k vars state defines modules xs)
(COMPILE-TOP/k
state modules macros defines dir body
(λ (state modules macros defines xs)
Expand Down Expand Up @@ -65,8 +65,8 @@
name n 0 export-values defines
(λ (defines cs1)
(LAMBDA/k state modules macros dir '() (append xs `((LISTz ,@(map second exports))))
(λ (state modules lam)
(k state defines (hash-set modules name (module export-macros export-values))
(λ (vars state modules lam)
(k vars state defines (hash-set modules name (module export-macros export-values))
(cons
($$define n ($$apply lam '())) cs1))))))))

Expand Down Expand Up @@ -114,8 +114,8 @@
(k vars state modules macros defines xs 'VOIDz))))]
[(or (eq? f 'lambda) (eq? f ))
(LAMBDA/k state modules macros dir (car args) (cdr args)
(λ (state modules lam)
(k vars state modules macros defines '() lam)))]
(λ (vars1 state modules lam)
(k (set-union vars1 vars) state modules macros defines '() lam)))]
[(eq? f 'LISTz)
(COMPILE/k*
vars state modules macros defines dir exp? args
Expand All @@ -125,8 +125,8 @@
(let ([name (car args)] [exports+body (cdr args)])
(MODULE/k
state name modules macros defines dir (car exports+body) (cdr exports+body)
(λ (state defines modules cs)
(k vars state modules macros defines cs $void))))]
(λ (vars1 state defines modules cs)
(k (set-union vars1 vars) state modules macros defines cs $void))))]
[(eq? f 'RECORDz)
(k vars state modules macros defines (list ($$record (car args) (cadr args) (cddr args))) $void)]
[(eq? f 'if)
Expand Down Expand Up @@ -183,8 +183,8 @@
[(eq? f 'IMPALLz) (error 'compile "invalid syntax" x)]
[(or (eq? f 'lambda) (eq? f ))
(LAMBDA/k state modules macros dir (car args) (cdr args)
(λ (state modules lam)
(k vars state modules macros defines ($$tail-val lam))))]
(λ (vars1 state modules lam)
(k (set-union vars1 vars) state modules macros defines ($$tail-val lam))))]
[(eq? f 'LISTz)
(COMPILE/k*
vars state modules macros defines dir #f args
Expand Down Expand Up @@ -283,11 +283,12 @@
[(symbol? args) (set args)]
[(null? args) null-set]
[else (set-add (args->set (cdr args)) (car args))]))
(define (LAMBDA/k state modules macros dir args body k) ; (k state modules lambda)
(define (LAMBDA/k state modules macros dir args body k) ; (k vars state modules lambda)
(BEGIN/tail
null-set state modules macros null-set dir body
(λ (vars state modules macros defines1 cs)
(k state modules ($$lambda (set->list (set-subtract vars (args->set args) defines1)) (set->list defines1) args cs)))))
(let ([vars (set-subtract vars (args->set args) defines1)])
(k vars state modules ($$lambda (set->list vars) (set->list defines1) args cs))))))
(define (HOST xs k1 k2)
(let ([x (car xs)] [xs (cdr xs)])
(let ([arch (first x)] [code (second x)])
Expand Down

0 comments on commit 43b010c

Please sign in to comment.