source: trunk/abcl/contrib/jss/optimize-java-call.lisp

Last change on this file was 15146, checked in by Mark Evenson, 5 years ago

JSS read sharp expression bugfixes
(Alan Ruttenberg)

Fix the following in JSS:

1) method call expression lookup java class for jstatic.
2) maybe-class, if it isn't a class, intern in current package vs. jss

Added missing <file:contrib/jss/util.lisp> from the head as of
github.com/alanruttenberg/abcl
with commit 2dab9f16384f279afe0127ef3c540811939c5bcb
<https://github.com/alanruttenberg/abcl/commit/0ce3f7d0e8003d2ca66cf59c4cd5d32a7c8f4f40>.

Untabify all source units for sanity.

Merges <https://github.com/armedbear/abcl/pull/65>.

Via
<https://github.com/armedbear/abcl/pull/65/commits/4461941d335feb298fd246f29967766c213b0e8c>,
<https://github.com/armedbear/abcl/pull/65/commits/3a681f852f0dc0581f8d47393e0d2d5d6e58596f>.

File size: 1.5 KB
Line 
1(in-package :jss)
2
3(defvar *inhibit-jss-optimization* nil)
4
5;; https://mailman.common-lisp.net/pipermail/armedbear-devel/2016-October/003726.html
6
7(precompiler::define-function-position-lambda-transform jss::invoke-restargs (arglist form args)
8  (declare (ignore arglist))
9  (unless *inhibit-jss-optimization*
10    (precompiler::precompile-function-call 
11     `(jss::invoke-restargs-macro
12          ,(second form)
13          ,(car args) (list ,@(cdr args)) ,(fifth form)))))
14
15(defmacro invoke-restargs-macro ( method object args &optional (raw? nil))
16  (assert (eq (car args) 'list))
17  (setq args (cdr args))
18  (if (and (consp object) (eq (car object) 'quote))
19      (let ((object (eval object)))
20        (let* ((object-as-class
21                 (or (ignore-errors (let ((*muffle-warnings* t)) (find-java-class object)))
22                     `(find-java-class ',object))))
23          (if raw?
24              `(jstatic-raw ,method ,object-as-class ,@args)
25              `(jstatic ,method ,object-as-class ,@args))))
26      (let ((objectvar (make-symbol "INVOKE-RESTARGS-ARG1")))
27        (if raw?
28            `(let ((,objectvar ,object))
29               (if (symbolp ,objectvar)
30                   (jstatic-raw ,method (find-java-class ,objectvar) ,@args)
31                   (jcall-raw ,method ,objectvar ,@args)))
32            `(let ((,objectvar ,object))
33               (if (symbolp ,objectvar)
34                   (jstatic ,method (find-java-class ,objectvar) ,@args)
35                   (jcall ,method ,objectvar ,@args)))))))
36
37
38
Note: See TracBrowser for help on using the repository browser.