Changeset 15366


Ignore:
Timestamp:
08/13/20 19:24:23 (3 years ago)
Author:
Mark Evenson
Message:

compiler: emit make-array for top-level specialized vector forms

When compiling top-level DEFVAR/DEFPARAMETER/DEFCONSTANT forms for
specialized vectors, preserve type information by emitting
CL:MAKE-ARRAY calls.

Fixes <https://github.com/armedbear/abcl/issues/266>.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compile-file.lisp

    r14915 r15366  
    1 
    21;;; compile-file.lisp
    32;;;
     
    268267  (note-toplevel-form form)
    269268  (eval form)
     269      ;;; emit make-array  when initial-value is a specialized vector
     270  (let ((initial-value (third form)))
     271    (when (and (atom initial-value)
     272               (arrayp initial-value)
     273               (= (length (array-dimensions initial-value)) 1)
     274               (not (eq (array-element-type initial-value) t)))
     275      (setf (third form)
     276            `(common-lisp:make-array
     277              ',(array-dimensions initial-value)
     278              :element-type ',(array-element-type initial-value)
     279              :initial-contents ',(coerce initial-value 'list)))))
    270280  `(progn
    271281     (put ',(second form) 'sys::source (cons '(,(second form) ,(namestring *source*) ,*source-position*) (get ',(second form)  'sys::source nil)))
     
    375385      (let ((name (second form)))
    376386        (%defvar name)))
    377   (let ((name (second form)))
     387  (let ((name (second form))
     388        (initial-value (third form)))
     389    ;;; emit make-array  when initial-value is a specialized vector
     390    (when (and (atom initial-value)
     391               (arrayp initial-value)
     392               (= (length (array-dimensions initial-value)) 1)
     393               (not (eq (array-element-type initial-value) t)))
     394      (setf (third form)
     395            `(common-lisp:make-array
     396              ',(array-dimensions initial-value)
     397              :element-type ',(array-element-type initial-value)
     398              :initial-contents ',(coerce initial-value 'list))))
    378399    `(progn
    379400       (put ',name 'sys::source (cons (list :variable ,(namestring *source*) ,*source-position*) (get ',name  'sys::source nil)))
    380       ,form)))
     401       ,form)))
     402
    381403
    382404(declaim (ftype (function (t t t) t) process-toplevel-defpackage/in-package))
Note: See TracChangeset for help on using the changeset viewer.