mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 14:50:19 +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:
parent
a431673924
commit
fdfb36de84
2 changed files with 17 additions and 7 deletions
|
@ -13,7 +13,6 @@ Already implemented:
|
||||||
Especially still missing:
|
Especially still missing:
|
||||||
* other progX forms, will be done in macros
|
* other progX forms, will be done in macros
|
||||||
* where, unless, will be done in macros
|
* where, unless, will be done in macros
|
||||||
* or
|
|
||||||
* while, other loops using macros
|
* while, other loops using macros
|
||||||
* catch/throw, unwind-protect
|
* catch/throw, unwind-protect
|
||||||
* real elisp reader instead of Scheme's
|
* real elisp reader instead of Scheme's
|
||||||
|
|
|
@ -35,9 +35,10 @@
|
||||||
props))))
|
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 (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
|
; Compile a symbol expression. This is a variable reference or maybe some
|
||||||
|
@ -46,11 +47,9 @@
|
||||||
(define (compile-symbol loc sym)
|
(define (compile-symbol loc sym)
|
||||||
(case sym
|
(case sym
|
||||||
|
|
||||||
((nil)
|
((nil) (nil-value loc))
|
||||||
(nil-value loc))
|
|
||||||
|
|
||||||
((t)
|
((t) (t-value loc))
|
||||||
(make-const loc #t))
|
|
||||||
|
|
||||||
; FIXME: Use fluids.
|
; FIXME: Use fluids.
|
||||||
(else
|
(else
|
||||||
|
@ -102,7 +101,7 @@
|
||||||
(make-sequence loc (map compile-expr (cdr cur)))
|
(make-sequence loc (map compile-expr (cdr cur)))
|
||||||
(iterate (cdr tail))))))))
|
(iterate (cdr tail))))))))
|
||||||
|
|
||||||
((and) (nil-value loc))
|
((and) (t-value loc))
|
||||||
((and . ,expressions)
|
((and . ,expressions)
|
||||||
(let iterate ((tail expressions))
|
(let iterate ((tail expressions))
|
||||||
(if (null? (cdr tail))
|
(if (null? (cdr tail))
|
||||||
|
@ -112,6 +111,18 @@
|
||||||
(iterate (cdr tail))
|
(iterate (cdr tail))
|
||||||
(nil-value loc)))))
|
(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)
|
(('quote ,val)
|
||||||
(make-const loc val))
|
(make-const loc val))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue