diff options
author | Mark H Weaver <mhw@netris.org> | 2012-01-14 03:27:35 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2012-01-14 03:27:35 -0500 |
commit | 39eb0b7297a0e5baad5d3dc34068c854fa4c0c8b (patch) | |
tree | b2f37e3d2dd117635871e951f79ffbbb6dea6b5b | |
parent | 88c0a1d5911e68aed20675948b15d7e67896df87 (diff) | |
download | guile-39eb0b7297a0e5baad5d3dc34068c854fa4c0c8b.tar.gz |
Fix serialization of #nil-terminated lists during compilation
* module/language/glil/compile-assembly.scm (scheme-list?): New
predicate, like `list?' but requires that the last cdr must be '(),
not #nil.
(dump-object, dump-constants): Use `list' opcode to create a list only
if it is terminated by '(). If it's terminated by #nil, we must use
the more general `cons' opcode.
-rw-r--r-- | module/language/glil/compile-assembly.scm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/module/language/glil/compile-assembly.scm b/module/language/glil/compile-assembly.scm index c76e41225..997f7c78d 100644 --- a/module/language/glil/compile-assembly.scm +++ b/module/language/glil/compile-assembly.scm @@ -103,6 +103,13 @@ (define (immediate? x) (object->assembly x)) +;; This tests for a proper scheme list whose last cdr is '(), not #nil. +;; +(define (scheme-list? x) + (or (eq? x '()) + (and (pair? x) + (scheme-list? (cdr x))))) + ;; Note: in all of these procedures that build up constant tables, the ;; first (zeroth) index is reserved. At runtime it is replaced with the ;; procedure's module. Hence all of this 1+ length business. @@ -733,7 +740,7 @@ ((keyword? x) `(,@(dump-object (keyword->symbol x) addr) (make-keyword))) - ((list? x) + ((scheme-list? x) (let ((tail (let ((len (length x))) (if (>= len 65536) (too-long "list")) `((list ,(quotient len 256) ,(modulo len 256)))))) @@ -815,7 +822,7 @@ (values code (addr+ addr code)))) ((variable-cache-cell? x) (dump1 (variable-cache-cell-key x) i addr)) - ((list? x) + ((scheme-list? x) (receive (codes addr) (fold2 (lambda (x codes addr) (receive (subcode addr) (ref-or-dump x i addr) |