summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ref/vm.texi4
-rw-r--r--libguile/vm-i-system.c6
-rw-r--r--module/language/assembly.scm2
-rw-r--r--module/language/elisp/compile-tree-il.scm15
-rw-r--r--module/language/glil/decompile-assembly.scm2
5 files changed, 24 insertions, 5 deletions
diff --git a/doc/ref/vm.texi b/doc/ref/vm.texi
index fa655238f..dd0c1ebed 100644
--- a/doc/ref/vm.texi
+++ b/doc/ref/vm.texi
@@ -756,6 +756,10 @@ Push @code{#f} onto the stack.
Push @code{#t} onto the stack.
@end deffn
+@deffn Instruction make-nil
+Push @code{%nil} onto the stack.
+@end deffn
+
@deffn Instruction make-eol
Push @code{'()} onto the stack.
@end deffn
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index d55d6e218..03d0c1711 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -107,6 +107,12 @@ VM_DEFINE_INSTRUCTION (8, make_false, "make-false", 0, 0, 1)
NEXT;
}
+VM_DEFINE_INSTRUCTION (57, make_nil, "make-nil", 0, 0, 1)
+{
+ PUSH (SCM_ELISP_NIL);
+ NEXT;
+}
+
VM_DEFINE_INSTRUCTION (9, make_eol, "make-eol", 0, 0, 1)
{
PUSH (SCM_EOL);
diff --git a/module/language/assembly.scm b/module/language/assembly.scm
index 3a0b3873e..6ccac99dd 100644
--- a/module/language/assembly.scm
+++ b/module/language/assembly.scm
@@ -106,6 +106,7 @@
(define (object->assembly x)
(cond ((eq? x #t) `(make-true))
((eq? x #f) `(make-false))
+ ((eq? x %nil) `(make-nil))
((null? x) `(make-eol))
((and (integer? x) (exact? x))
(cond ((and (<= -128 x) (< x 128))
@@ -131,6 +132,7 @@
(pmatch code
((make-true) #t)
((make-false) #f) ;; FIXME: Same as the `else' case!
+ ((make-nil) %nil)
((make-eol) '())
((make-int8 ,n)
(if (< n 128) n (- n 256)))
diff --git a/module/language/elisp/compile-tree-il.scm b/module/language/elisp/compile-tree-il.scm
index 8507bc08c..dbc100477 100644
--- a/module/language/elisp/compile-tree-il.scm
+++ b/module/language/elisp/compile-tree-il.scm
@@ -35,6 +35,11 @@
props))))
+; Value to use for Elisp's nil.
+
+(define (nil-value loc) (make-const loc %nil))
+
+
; Compile a symbol expression. This is a variable reference or maybe some
; special value like nil.
@@ -42,7 +47,7 @@
(case sym
((nil)
- (make-const loc #f))
+ (nil-value loc))
((t)
(make-const loc #t))
@@ -63,7 +68,7 @@
((if ,condition ,ifclause)
(make-conditional loc (compile-expr condition)
(compile-expr ifclause)
- (make-const loc #f)))
+ (nil-value loc)))
((if ,condition ,ifclause ,elseclause)
(make-conditional loc (compile-expr condition)
(compile-expr ifclause)
@@ -79,14 +84,14 @@
clauses))
(let iterate ((tail clauses))
(if (null? tail)
- (make-const loc #f)
+ (nil-value loc)
(let ((cur (car tail)))
(make-conditional loc
(compile-expr (car cur))
(make-sequence loc (map compile-expr (cdr cur)))
(iterate (cdr tail)))))))
- ((and) (make-const loc #t))
+ ((and) (nil-value loc))
((and . ,expressions)
(let iterate ((tail expressions))
(if (null? (cdr tail))
@@ -94,7 +99,7 @@
(make-conditional loc
(compile-expr (car tail))
(iterate (cdr tail))
- (make-const loc #f)))))
+ (nil-value loc)))))
(('quote ,val)
(make-const loc val))
diff --git a/module/language/glil/decompile-assembly.scm b/module/language/glil/decompile-assembly.scm
index 502ef8034..6c222ba31 100644
--- a/module/language/glil/decompile-assembly.scm
+++ b/module/language/glil/decompile-assembly.scm
@@ -131,6 +131,8 @@
(lp (cdr in) stack out (1+ pos)))
((make-false)
(lp (cdr in) (cons #f stack) out (1+ pos)))
+ ((make-nil)
+ (lp (cdr in) (cons %nil stack) out (1+ pos)))
((load-program ,a ,b ,c ,d ,labels ,sublen ,meta . ,body)
(lp (cdr in)
(cons (decompile-load-program a b c d (decompile-meta meta)