- Timestamp:
- 05/11/09 21:12:17 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp
r11839 r11856 52 52 bindings))) 53 53 54 (defun generate-special-declarations (bindings) 55 (let ((*package* (find-package :abcl-script-user))) 56 `(declare (special 57 ,@(mapcar (lambda (binding) (read-from-string (car binding))) 58 bindings))))) 59 54 60 (defun generate-java-bindings (bindings-list actual-bindings java-bindings) 55 61 (loop :for binding :in actual-bindings … … 73 79 (eval `(let (,@,actual-global-bindings) 74 80 (let (,@,actual-engine-bindings) 81 ,(generate-special-declarations ,global-bindings) 82 ,(generate-special-declarations ,engine-bindings) 75 83 (prog1 76 84 (progn ,@,body) … … 88 96 code-string script-context) 89 97 (eval-in-script-context (global-bindings engine-bindings stdin stdout script-context) 90 (read-from-string91 (concatenate 'string "(" code-string ")"))))98 `((with-input-from-string (str ,code-string) 99 (sys::load-returning-last-result str))))) 92 100 93 101 (defun eval-compiled-script (global-bindings engine-bindings stdin stdout … … 97 105 98 106 (defun compile-script (code-string) 99 (if *compile-using-temp-files* 100 (let* ((tmp-file (jstatic (jmethod "java.io.File" "createTempFile" "java.lang.String" "java.lang.String") 101 nil "abcl-src-file-" ".lisp")) 102 (tmp-file-path (jcall (jmethod "java.io.File" "getAbsolutePath") tmp-file))) 103 (jcall (jmethod "java.io.File" "deleteOnExit") tmp-file) ;to be really-really-really sure... 104 (unwind-protect 105 (progn 106 (with-open-file (stream tmp-file-path :direction :output) 107 (princ "(in-package :abcl-script-user)" stream) 108 (princ code-string stream) 109 (finish-output stream)) 110 (let ((compiled-file (compile-file tmp-file-path))) 111 (jcall (jmethod "java.io.File" "deleteOnExit") 112 (jnew (jconstructor "java.io.File" "java.lang.String") 113 (namestring compiled-file))) 114 (lambda () 115 (let ((*package* (find-package :abcl-script-user))) 116 (load compiled-file :verbose t :print t))))) 117 (delete-file tmp-file-path))) 118 (eval 119 `(compile 120 nil 121 (lambda () 122 ,@(let ((*package* (find-package :abcl-script-user))) 123 (read-from-string 124 (concatenate 'string "(" code-string " cl:t)")))))))) ;return T in conformity of what LOAD does. 107 (let* ((tmp-file (jstatic (jmethod "java.io.File" "createTempFile" "java.lang.String" "java.lang.String") 108 nil "abcl-src-file-" ".lisp")) 109 (tmp-file-path (jcall (jmethod "java.io.File" "getAbsolutePath") tmp-file))) 110 (jcall (jmethod "java.io.File" "deleteOnExit") tmp-file) ;to be really-really-really sure... 111 (unwind-protect 112 (progn 113 (with-open-file (stream tmp-file-path :direction :output) 114 (princ "(in-package :abcl-script-user)" stream) 115 (princ code-string stream) 116 (finish-output stream)) 117 (let ((compiled-file (compile-file tmp-file-path))) 118 (jcall (jmethod "java.io.File" "deleteOnExit") 119 (jnew (jconstructor "java.io.File" "java.lang.String") 120 (namestring compiled-file))) 121 (lambda () 122 (let ((*package* (find-package :abcl-script-user))) 123 (sys::load-returning-last-result compiled-file))))) 124 (delete-file tmp-file-path)))) 125 125 126 126 ;;Java interface implementation - TODO
Note: See TracChangeset
for help on using the changeset viewer.