Created
November 21, 2018 15:43
-
-
Save stassats/ccbf0d95a320acf74d31d04891e1a2fd to your computer and use it in GitHub Desktop.
x.diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/lisp/kernel/cleavir/inline-prep.lisp b/src/lisp/kernel/cleavir/inline-prep.lisp | |
| index df020fd6f..ad25aa21b 100644 | |
| --- a/src/lisp/kernel/cleavir/inline-prep.lisp | |
| +++ b/src/lisp/kernel/cleavir/inline-prep.lisp | |
| @@ -119,10 +119,7 @@ | |
| #-cst | |
| (cleavir-generate-ast:generate-ast | |
| function-form (cleavir-env:compile-time env) *clasp-system*)))) | |
| - `(eval-when (:compile-toplevel :load-toplevel :execute) | |
| - (when (core:declared-global-inline-p ',name) | |
| - (when (fboundp ',name) | |
| - (setf (inline-ast ',name) ,ast))))))) | |
| + ast))) | |
| (export '(*simple-environment* *code-walker*)) | |
| diff --git a/src/lisp/kernel/clos/kernel.lsp b/src/lisp/kernel/clos/kernel.lsp | |
| index 680664c44..a47c3b527 100644 | |
| --- a/src/lisp/kernel/clos/kernel.lsp | |
| +++ b/src/lisp/kernel/clos/kernel.lsp | |
| @@ -75,6 +75,7 @@ | |
| qualifiers specializers lambda-list | |
| fun options))) | |
| (add-method gf method) | |
| + (maybe-augment-generic-function-lambda-list name lambda-list) | |
| method)) | |
| ;;; ---------------------------------------------------------------------- | |
| diff --git a/src/lisp/kernel/clos/method.lsp b/src/lisp/kernel/clos/method.lsp | |
| index b12f00e3e..095a353f8 100644 | |
| --- a/src/lisp/kernel/clos/method.lsp | |
| +++ b/src/lisp/kernel/clos/method.lsp | |
| @@ -108,19 +108,17 @@ in the generic function lambda-list to the generic function lambda-list" | |
| `(progn | |
| (eval-when (:compile-toplevel) | |
| (cmp:register-global-function-def 'defmethod ',name)) | |
| - (prog1 | |
| - (install-method ',name ',qualifiers | |
| - ,(specializers-expression specializers) | |
| - ',lambda-list | |
| - ,fn-form | |
| - ;; Note that we do not quote the options returned by make-method-lambda. | |
| - ;; This is essentially to make the fast method function easier. | |
| - ;; MOP is in my view ambiguous about whether they're supposed to be quoted. | |
| - ;; There's an example that sort of implies they are, but the extra | |
| - ;; flexibility is pretty convenient, and matches that the primary value is | |
| - ;; of course evaluated. | |
| - ,@options) | |
| - (maybe-augment-generic-function-lambda-list ',name ',lambda-list))))))))) | |
| + (install-method ',name ',qualifiers | |
| + ,(specializers-expression specializers) | |
| + ',lambda-list | |
| + ,fn-form | |
| + ;; Note that we do not quote the options returned by make-method-lambda. | |
| + ;; This is essentially to make the fast method function easier. | |
| + ;; MOP is in my view ambiguous about whether they're supposed to be quoted. | |
| + ;; There's an example that sort of implies they are, but the extra | |
| + ;; flexibility is pretty convenient, and matches that the primary value is | |
| + ;; of course evaluated. | |
| + ,@options)))))))) | |
| (defun specializers-expression (specializers) | |
| `(list ,@(loop for spec in specializers | |
| diff --git a/src/lisp/kernel/init.lsp b/src/lisp/kernel/init.lsp | |
| index d8de83e69..15ed8b112 100644 | |
| --- a/src/lisp/kernel/init.lsp | |
| +++ b/src/lisp/kernel/init.lsp | |
| @@ -331,8 +331,6 @@ as a VARIABLE doc and can be retrieved by (documentation 'NAME 'variable)." | |
| (defvar *print-radix* nil) | |
| (defvar *read-default-float-format* 'double-float) | |
| - | |
| - | |
| (core::export 'defun) | |
| (eval-when (:execute :compile-toplevel :load-toplevel) | |
| (core::select-package :core)) | |
| @@ -342,6 +340,12 @@ as a VARIABLE doc and can be retrieved by (documentation 'NAME 'variable)." | |
| (defvar *special-init-defun-symbol* (gensym "special-init-defun-symbol")) | |
| +(si:fset '%defun | |
| + #'(lambda (name function lambda-list &optional inline-ast) | |
| + (funcall #'(setf fdefinition) function name) | |
| + (setf-lambda-list function lambda-list) | |
| + name)) | |
| + | |
| ;;; A temporary definition of defun - the real one is in evalmacros | |
| #+clasp-min | |
| (eval-when (:execute) | |
| diff --git a/src/lisp/kernel/lsp/evalmacros.lsp b/src/lisp/kernel/lsp/evalmacros.lsp | |
| index 657f89cf8..10fcd9676 100644 | |
| --- a/src/lisp/kernel/lsp/evalmacros.lsp | |
| +++ b/src/lisp/kernel/lsp/evalmacros.lsp | |
| @@ -99,6 +99,18 @@ VARIABLE doc and can be retrieved by (DOCUMENTATION 'SYMBOL 'VARIABLE)." | |
| `(defconstant-eqx ,var ,form equal ,doc-string)) | |
| (export '(defconstant-equal)) | |
| +(defun set-inline-ast (name ast) | |
| + (when (and | |
| + (core:declared-global-inline-p name) | |
| + (fboundp name)) | |
| + (setf (inline-ast ast) ast))) | |
| + | |
| +(defun %defun (name function lambda-list &optional inline-ast) | |
| + (funcall #'(setf fdefinition) function name) | |
| + (setf-lambda-list function lambda-list) | |
| + (when inline-ast | |
| + (set-inline-ast name inline-ast)) | |
| + name) | |
| (defmacro defun (&whole whole name vl &body body &environment env) | |
| ;; Documentation in help.lsp | |
| @@ -113,19 +125,18 @@ VARIABLE doc and can be retrieved by (DOCUMENTATION 'SYMBOL 'VARIABLE)." | |
| (block ,(si::function-block-name name) ,@body)))) | |
| ;;(bformat t "macro expansion of defun current-source-location -> %s%N" current-source-location) | |
| ;;(bformat t "DEFUN global-function --> %s%N" global-function ) | |
| - `(progn | |
| - (eval-when (:compile-toplevel) | |
| - ;; this function won't be ready for a while, but it's okay as there's no | |
| - ;; compiler to run :compile-toplevel forms anyway. | |
| - (cmp::register-global-function-def 'defun ',name)) | |
| - (let ((,fn ,global-function)) | |
| - (funcall #'(setf fdefinition) ,fn ',name) | |
| - (setf-lambda-list ,fn ',vl) | |
| - ,@(si::expand-set-documentation name 'function doc-string) | |
| - ;; This can't be at toplevel. | |
| - ,@(and *defun-inline-hook* | |
| - (list (funcall *defun-inline-hook* name global-function env))) | |
| - ',name))))) | |
| + (let ((inline-ast (and *defun-inline-hook* | |
| + (funcall *defun-inline-hook* name global-function env)))) | |
| + `(progn | |
| + (eval-when (:compile-toplevel) | |
| + ;; this function won't be ready for a while, but it's okay as there's no | |
| + ;; compiler to run :compile-toplevel forms anyway. | |
| + (cmp::register-global-function-def 'defun ',name) | |
| + ;; ,@(when inline-ast | |
| + ;; `((set-inline-ast ',name ,inline-ast))) | |
| + ) | |
| + (%defun ',name ,global-function ',vl | |
| + ,@(and inline-ast `(,inline-ast)))))))) | |
| ;;; | |
| ;;; This is a no-op unless the compiler is installed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment