Changeset 8622


Ignore:
Timestamp:
02/21/05 18:28:55 (16 years ago)
Author:
piso
Message:

PROCESS-DEFCONSTANT

File:
1 edited

Legend:

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

    r8605 r8622  
    22;;;
    33;;; Copyright (C) 2004-2005 Peter Graves
    4 ;;; $Id: compile-file.lisp,v 1.56 2005-02-18 18:19:39 piso Exp $
     4;;; $Id: compile-file.lisp,v 1.57 2005-02-21 18:28:55 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    5959         (report-error
    6060          (load-compiled-function classfile)))))
     61
     62(defun dump-form (form stream)
     63  (when (and (consp form) (neq (car form) 'QUOTE))
     64    (let ((*print-fasl* t)
     65          (*print-level* nil)
     66          (*print-length* nil)
     67          (*print-circle* nil))
     68      (if (eq (car form) 'IMPORT)
     69          ;; Make sure package prefix is printed when symbols are imported.
     70          (let ((*package* (find-package "COMMON-LISP")))
     71            (write form :stream stream))
     72          (write form :stream stream)))
     73    (terpri stream)))
     74
     75(defun process-defconstant (form stream)
     76  ;; "If a DEFCONSTANT form appears as a top level form, the compiler
     77  ;; must recognize that [the] name names a constant variable. An
     78  ;; implementation may choose to evaluate the value-form at compile
     79  ;; time, load time, or both. Therefore, users must ensure that the
     80  ;; initial-value can be evaluated at compile time (regardless of
     81  ;; whether or not references to name appear in the file) and that
     82  ;; it always evaluates to the same value."
     83  (eval form)
     84  (cond ((structure-object-p (third form))
     85         (format t "PROCESS-DEFCONSTANT calling MAKE-LOAD-FORM ...~%")
     86         (multiple-value-bind (creation-form initialization-form)
     87             (make-load-form (third form))
     88           (dump-form (list 'DEFCONSTANT (second form) creation-form) stream)))
     89        (t
     90         (dump-form form stream))))
    6191
    6292(defun process-toplevel-form (form stream compile-time-too)
     
    83113                  (%defvar name))))
    84114           (DEFCONSTANT
    85             ;; "If a DEFCONSTANT form appears as a top level form, the compiler
    86             ;; must recognize that [the] name names a constant variable. An
    87             ;; implementation may choose to evaluate the value-form at compile
    88             ;; time, load time, or both. Therefore, users must ensure that the
    89             ;; initial-value can be evaluated at compile time (regardless of
    90             ;; whether or not references to name appear in the file) and that
    91             ;; it always evaluates to the same value."
    92             (eval form))
     115            (process-defconstant form stream)
     116            (return-from process-toplevel-form))
    93117           (DEFUN
    94118            (let* ((name (second form))
     
    202226            (when compile-time-too
    203227              (eval form))))))
    204   (when (and (consp form) (neq (car form) 'QUOTE))
    205     (let ((*print-fasl* t)
    206           (*print-level* nil)
    207           (*print-length* nil)
    208           (*print-circle* nil))
    209       (if (eq (car form) 'IMPORT)
    210           ;; Make sure package prefix is printed when symbols are imported.
    211           (let ((*package* (find-package "COMMON-LISP")))
    212             (write form :stream stream))
    213           (write form :stream stream)))
    214     (terpri stream)))
     228;;   (when (and (consp form) (neq (car form) 'QUOTE))
     229;;     (let ((*print-fasl* t)
     230;;           (*print-level* nil)
     231;;           (*print-length* nil)
     232;;           (*print-circle* nil))
     233;;       (if (eq (car form) 'IMPORT)
     234;;           ;; Make sure package prefix is printed when symbols are imported.
     235;;           (let ((*package* (find-package "COMMON-LISP")))
     236;;             (write form :stream stream))
     237;;           (write form :stream stream)))
     238;;     (terpri stream))
     239  (dump-form form stream)
     240  )
    215241
    216242(defun process-toplevel-progn (forms stream compile-time-too)
Note: See TracChangeset for help on using the changeset viewer.