1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 06:20:23 +02:00

Implemented elisp's or form.

* module/language/elisp/README: Document this.
* module/language/elisp/compile-tree-il.scm: Implement or.
This commit is contained in:
Daniel Kraft 2009-07-02 21:22:25 +02:00
parent a431673924
commit fdfb36de84
2 changed files with 17 additions and 7 deletions

View file

@ -13,7 +13,6 @@ Already implemented:
Especially still missing:
* other progX forms, will be done in macros
* where, unless, will be done in macros
* or
* while, other loops using macros
* catch/throw, unwind-protect
* real elisp reader instead of Scheme's

View file

@ -35,9 +35,10 @@
props))))
; Value to use for Elisp's nil.
; Value to use for Elisp's nil and t.
(define (nil-value loc) (make-const loc #f))
(define (t-value loc) (make-const loc #t))
; Compile a symbol expression. This is a variable reference or maybe some
@ -46,11 +47,9 @@
(define (compile-symbol loc sym)
(case sym
((nil)
(nil-value loc))
((nil) (nil-value loc))
((t)
(make-const loc #t))
((t) (t-value loc))
; FIXME: Use fluids.
(else
@ -102,7 +101,7 @@
(make-sequence loc (map compile-expr (cdr cur)))
(iterate (cdr tail))))))))
((and) (nil-value loc))
((and) (t-value loc))
((and . ,expressions)
(let iterate ((tail expressions))
(if (null? (cdr tail))
@ -112,6 +111,18 @@
(iterate (cdr tail))
(nil-value loc)))))
((or . ,expressions)
(let iterate ((tail expressions))
(if (null? tail)
(nil-value loc)
(let ((var (gensym)))
(make-let loc
'(condition) `(,var) `(,(compile-expr (car tail)))
(make-conditional loc
(make-lexical-ref loc 'condition var)
(make-lexical-ref loc 'condition var)
(iterate (cdr tail))))))))
(('quote ,val)
(make-const loc val))