diff --git a/module/language/elisp/README b/module/language/elisp/README index 160df3554..fab9f6230 100644 --- a/module/language/elisp/README +++ b/module/language/elisp/README @@ -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 diff --git a/module/language/elisp/compile-tree-il.scm b/module/language/elisp/compile-tree-il.scm index 8c0c3bb2b..ae2753327 100644 --- a/module/language/elisp/compile-tree-il.scm +++ b/module/language/elisp/compile-tree-il.scm @@ -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))