From dff649db1388fbb48ee4c1589c68c728c5531b0b Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Wed, 6 Aug 2003 08:50:41 +0000 Subject: [PATCH] AUTOLOAD facility implemented --- src/lsp/autoload.lsp | 66 ++++++++------------------------------------ 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/src/lsp/autoload.lsp b/src/lsp/autoload.lsp index 310a94075..a12bc18a8 100644 --- a/src/lsp/autoload.lsp +++ b/src/lsp/autoload.lsp @@ -12,9 +12,10 @@ ;;; Program Development Environment +(in-package "SYSTEM") + #+PDE (progn -(in-package "SYSTEM") (setq *record-source-pathname-p* nil) (defun record-source-pathname (symbol type) ;; type is either: @@ -37,9 +38,6 @@ (put-sysprop symbol alist (car type)))))) ) -;;; Go into LISP. -(in-package "LISP") - (defun lisp-implementation-type () "Args: () Returns the string \"ECL\"." @@ -51,60 +49,20 @@ Returns the string \"ECL\"." (defvar *compile-file-truename* nil) +(defun autoload (pathname &rest function-names) + (dolist (fname function-names) + (let ((thename fname)) + (fset fname #'(lambda (&rest args) + (load pathname) + (apply thename args)))))) + (unless (fboundp 'compile) (defun proclaim (d) "Args: (decl-spec) Gives a global declaration. See DECLARE for possible DECL-SPECs." - (when (eq (car d) 'SPECIAL) (mapc #'sys::*make-special (cdr d)))) + (when (eq (car d) 'SPECIAL) (mapc #'sys::*make-special (cdr d)))) -(defun compile-file (&rest args) - "Args: (input-pathname - &key output-file (load nil) - (o-file t) (c-file nil) (h-file nil) (data-file nil)) -Compiles the file specified by INPUT-PATHNAME and generates a fasl file -specified by OUTPUT-FILE. If the filetype is not specified in INPUT-PATHNAME, -then \".lsp\" is used as the default file type for the source file. LOAD -specifies whether to load the generated fasl file after compilation. The -:O-FILE, :C-FILE, :H-FILE, and :DATA-FILE keyword parameters allow you to -control the intermediate files generated by the ECL compiler.If the file was -compiled successfully, returns the pathname of the compiled file" - (load "SYS:cmp") - (apply 'compile-file args)) - -(defun compile (&rest args) - "Args: (name &optional (definition nil)) -If DEFINITION is NIL, NAME must be the name of a not-yet-compiled function. -In this case, COMPILE compiles the function, installs the compiled function as -the global function definition of NAME, and returns NAME. If DEFINITION is -non-NIL, it must be a lambda expression and NAME must be a symbol. COMPILE -compiles the lambda expression, installs the compiled function as the function -definition of NAME, and returns NAME. There is only one exception for this: -If NAME is NIL, then the compiled function is not installed but is simply -returned as the value of COMPILE. In any case, COMPILE creates temporary -files, whose filenames begin with \"gazonk\", which are automatically deleted -after compilation." - (load "SYS:cmp") - (apply 'compile args)) - -(defun compile-file-pathname (&rest args) - (load "SYS:cmp") - (apply 'compile-file-pathname args)) - -(defun disassemble (f &rest args) - "Args: (&optional (thing nil) &key (h-file nil) (data-file nil)) -Compiles the form specified by THING and prints the intermediate C language -code for that form. But does not install the result of compilation. If THING -is NIL, then the previously DISASSEMBLEd form is re-DISASSEMBLEd. If THING is -a symbol that names a function not yet compiled, the function definition is -disassembled. If THING is a lambda expression, it is disassembled as a -function definition. Otherwise, THING itself is disassembled as a top-level -form. H-FILE and DATA-FILE specify intermediate files to build a fasl file -from the C language code. NIL means \"do not create the file\"." - (when (si::valid-function-name-p f) - (setq function (fdefinition f))) - (unless (si::bc-disassemble f) - (load "SYS:cmp") - (apply 'disassemble f args))) +(autoload "SYS:cmp" 'compile-file 'compile 'compile-file-pathname 'disassemble) ) (defmacro with-compilation-unit (options &rest body) @@ -121,8 +79,6 @@ Report for details." ;;; Allocator. -(in-package "SYSTEM") - (defvar *type-list* '(cons ;; fixnum Beppe