Ignore:
Timestamp:
05/07/09 22:01:52 (14 years ago)
Author:
astalla
Message:

Fixed compilation with temp files with JSR-223. Refactoring of AbclScriptEngine?
(mostly elimination of dead code). Changed policy of use of #'sys::%debugger-hook-function
in an attempt to have the throwing debugger cover more cases; it still doesn't
work always.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp

    r11623 r11839  
    5858       ,java-bindings ,(car jbinding) ,(car binding))))
    5959
    60 (defmacro with-script-context ((global-bindings engine-bindings stdin stdout script-context)
    61              body)
     60(defmacro eval-in-script-context ((global-bindings engine-bindings stdin stdout script-context)
     61          body)
     62  "Sets up an environment in which to evaluate a piece of code coming from Java through the JSR-223 methods."
    6263  (let ((actual-global-bindings (gensym))
    6364  (actual-engine-bindings (gensym)))
     
    6566     (*standard-input* ,stdin)
    6667     (*standard-output* ,stdout)
     68     (*debugger-hook* (if *use-throwing-debugger*
     69        #'sys::%debugger-hook-function
     70        *debugger-hook*))
    6771     (,actual-global-bindings (generate-bindings ,global-bindings))
    6872     (,actual-engine-bindings (generate-bindings ,engine-bindings)))
    69       (eval `(let ((*standard-input* ,,stdin)
    70        (*standard-output* ,,stdout)
    71        (*package* (find-package :abcl-script-user)))
    72         (let (,@,actual-global-bindings)
     73       (eval `(let (,@,actual-global-bindings)
    7374    (let (,@,actual-engine-bindings)
    7475      (prog1
     
    8283           ,engine-bindings
    8384           ,actual-engine-bindings
    84            (jcall +get-bindings+ ,script-context +engine-scope+))))))))))
     85           (jcall +get-bindings+ ,script-context +engine-scope+)))))))))
    8586 
    8687(defun eval-script (global-bindings engine-bindings stdin stdout
    8788        code-string script-context)
    88   (with-script-context (global-bindings engine-bindings stdin stdout script-context)
     89  (eval-in-script-context (global-bindings engine-bindings stdin stdout script-context)
    8990    (read-from-string
    9091     (concatenate 'string "(" code-string ")"))))
     
    9293(defun eval-compiled-script (global-bindings engine-bindings stdin stdout
    9394           function script-context)
    94   (with-script-context (global-bindings engine-bindings stdin stdout script-context)
     95  (eval-in-script-context (global-bindings engine-bindings stdin stdout script-context)
    9596    `((funcall ,function))))
    9697
     
    103104  (unwind-protect
    104105       (progn
    105          (with-open-file (stream tmp-file-path :direction :output :if-exists :overwrite)
    106      (prin1 code-string stream)
     106         (with-open-file (stream tmp-file-path :direction :output)
     107     (princ "(in-package :abcl-script-user)" stream)
     108     (princ code-string stream)
    107109     (finish-output stream))
    108110         (let ((compiled-file (compile-file tmp-file-path)))
     
    110112      (jnew (jconstructor "java.io.File" "java.lang.String")
    111113            (namestring compiled-file)))
    112      (lambda () (load compiled-file))))
     114     (lambda ()
     115       (let ((*package* (find-package :abcl-script-user)))
     116         (load compiled-file :verbose t :print t)))))
    113117    (delete-file tmp-file-path)))
    114118      (eval
     
    117121   (lambda ()
    118122     ,@(let ((*package* (find-package :abcl-script-user)))
    119       (read-from-string (concatenate 'string "(" code-string ")"))))))))
     123         (read-from-string
     124    (concatenate 'string "(" code-string " cl:t)")))))))) ;return T in conformity of what LOAD does.
    120125
    121 ;;Java interface implementation
     126;;Java interface implementation - TODO
    122127
    123128(defvar *interface-implementation-map* (make-hash-table :test #'equal))
     
    126131  (gethash interface *interface-implementation-map*))
    127132
    128 (defun register-java-interface-implementation (interface impl)
    129   (setf (gethash interface *interface-implementation-map*) impl))
     133(defun register-java-interface-implementation (interface implementation &optional lisp-this)
     134  (setf (gethash interface *interface-implementation-map*)
     135  (jmake-proxy interface implementation lisp-this)))
    130136
    131137(defun remove-java-interface-implementation (interface)
    132138  (remhash interface *interface-implementation-map*))
    133139
    134 (defun define-java-interface-implementation (interface implementation &optional lisp-this)
    135   (register-java-interface-implementation
    136    interface
    137    (jmake-proxy interface implementation lisp-this)))
    138 
    139140;Let's load it so asdf package is already defined when loading config.lisp
    140141(require 'asdf)
Note: See TracChangeset for help on using the changeset viewer.