;; If a file, the truename of the corresponding source file. If from
;; a Lisp form, :LISP. If from a stream, :STREAM.
(name (missing-arg) :type (or pathname (member :lisp :stream)))
+ ;; the external format that we'll call OPEN with, if NAME is a file.
+ (external-format nil)
;; the defaulted, but not necessarily absolute file name (i.e. prior
;; to TRUENAME call.) Null if not a file. This is used to set
;; *COMPILE-FILE-PATHNAME*, and if absolute, is dumped in the
(stream nil :type (or stream null)))
;;; Given a pathname, return a SOURCE-INFO structure.
-(defun make-file-source-info (file)
+(defun make-file-source-info (file external-format)
(let ((file-info (make-file-info :name (truename file)
:untruename file
+ :external-format external-format
:write-date (file-write-date file))))
(make-source-info :file-info file-info)))
(declare (type source-info info))
(or (source-info-stream info)
(let* ((file-info (source-info-file-info info))
- (name (file-info-name file-info)))
+ (name (file-info-name file-info))
+ (external-format (file-info-external-format file-info)))
(setf sb!xc:*compile-file-truename* name
sb!xc:*compile-file-pathname* (file-info-untruename file-info)
- (source-info-stream info) (open name :direction :input)))))
+ (source-info-stream info)
+ (open name :direction :input
+ :external-format external-format)))))
;;; Close the stream in INFO if it is open.
(defun close-source-info (info)
#!+sb-doc
"Compile INPUT-FILE, producing a corresponding fasl file and returning
its filename. Besides the ANSI &KEY arguments :OUTPUT-FILE, :VERBOSE,
- :PRINT, and :EXTERNAL-FORMAT,the following extensions are supported:
+ :PRINT, and :EXTERNAL-FORMAT, the following extensions are supported:
:TRACE-FILE
If given, internal data structures are dumped to the specified
file, or if a value of T is given, to a file of *.trace type
optimization values, and the :BLOCK-COMPILE argument will probably
become deprecated."
- (unless (eq external-format :default)
- (error "Non-:DEFAULT EXTERNAL-FORMAT values are not supported."))
(let* ((fasl-output nil)
(output-file-name nil)
(compile-won nil)
(warnings-p nil)
(failure-p t) ; T in case error keeps this from being set later
(input-pathname (verify-source-file input-file))
- (source-info (make-file-source-info input-pathname))
+ (source-info (make-file-source-info input-pathname external-format))
(*compiler-trace-output* nil)) ; might be modified below
(unwind-protect
;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.
+(defvar *tmp-filename* "load-test.tmp")
+
;;; Bug reported by Sean Ross: FASL loader set fill pointer to loaded
;;; simple arrays.
+
(defvar *array*)
-(defvar *tmp-filename* "load-test.tmp")
(progn
(with-open-file (s *tmp-filename*
(when tmp-fasl (delete-file tmp-fasl))
(delete-file *tmp-filename*))))
+;;; rudimentary external-format test
+(dolist (ef '(:default :ascii :latin-1 :utf-8))
+ (with-open-file (s *tmp-filename*
+ :direction :output
+ :if-exists :supersede
+ :if-does-not-exist :create)
+ (print '(defun foo (x) (1+ x)) s))
+ (fmakunbound 'foo)
+ (let (tmp-fasl)
+ (unwind-protect
+ (progn
+ (setq tmp-fasl (compile-file *tmp-filename* :external-format ef))
+ (load tmp-fasl)
+ (assert (= (foo 1) 2)))
+ (when tmp-fasl (delete-file tmp-fasl))
+ (delete-file *tmp-filename*))))
+
(quit :unix-status 104)