From 39eb0b7297a0e5baad5d3dc34068c854fa4c0c8b Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sat, 14 Jan 2012 03:27:35 -0500 Subject: [PATCH] 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. --- 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 c76e412..997f7c7 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) -- 1.7.5.4