Changeset 11623


Ignore:
Timestamp:
02/04/09 21:58:25 (12 years ago)
Author:
astalla
Message:

Perfectioned ABCL auto-configuration when using JSR-223; added option to
compile scripts using temp files (default) or using the run-time
compiler; added example of usage of ABCL with JSR-223.

Location:
trunk/abcl
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngine.java

    r11618 r11623  
    4444  private Function compileScript;
    4545  private Function evalCompiledScript;
    46   private boolean configured = false;
    47 
    48   public AbclScriptEngine(boolean enableThrowingDebugger) {
    49     this();
    50     if (enableThrowingDebugger) {
    51       try {
    52         installThrowingDebuggerHook(LispThread.currentThread());
    53       } catch (ConditionThrowable e) {
    54         throw new InternalError("Can't set throwing debugger hook!");
    55       }
    56     }
    57   }
    5846
    5947  public AbclScriptEngine() {
     
    7765    }
    7866  }
    79  
    80   public boolean isConfigured() {
    81     return configured;
    82   }
    83  
     67   
    8468  public Interpreter getInterpreter() {
    8569    return interpreter;
  • trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngineFactory.java

    r11450 r11623  
    2929public class AbclScriptEngineFactory implements ScriptEngineFactory {
    3030
    31   private static final AbclScriptEngine THE_ONLY_ONE_ENGINE = new AbclScriptEngine(true);
     31    private static final AbclScriptEngine THE_ONLY_ONE_ENGINE = new AbclScriptEngine();
    3232 
    3333  @Override
  • trunk/abcl/src/org/armedbear/lisp/scripting/lisp/abcl-script.lisp

    r11618 r11623  
    9696
    9797(defun compile-script (code-string)
    98   (eval
    99    `(compile
    100      nil
    101      (lambda ()
    102        ,@(let ((*package* (find-package :abcl-script-user)))
    103         (read-from-string (concatenate 'string "(" code-string ")")))))))
    104 
     98  (if *compile-using-temp-files*
     99      (let* ((tmp-file (jstatic (jmethod "java.io.File" "createTempFile" "java.lang.String" "java.lang.String")
     100        nil "abcl-src-file-" ".lisp"))
     101       (tmp-file-path (jcall (jmethod "java.io.File" "getAbsolutePath") tmp-file)))
     102  (jcall (jmethod "java.io.File" "deleteOnExit") tmp-file) ;to be really-really-really sure...
     103  (unwind-protect
     104       (progn
     105         (with-open-file (stream tmp-file-path :direction :output :if-exists :overwrite)
     106     (prin1 code-string stream)
     107     (finish-output stream))
     108         (let ((compiled-file (compile-file tmp-file-path)))
     109     (jcall (jmethod "java.io.File" "deleteOnExit")
     110      (jnew (jconstructor "java.io.File" "java.lang.String")
     111            (namestring compiled-file)))
     112     (lambda () (load compiled-file))))
     113    (delete-file tmp-file-path)))
     114      (eval
     115       `(compile
     116   nil
     117   (lambda ()
     118     ,@(let ((*package* (find-package :abcl-script-user)))
     119      (read-from-string (concatenate 'string "(" code-string ")"))))))))
    105120
    106121;;Java interface implementation
  • trunk/abcl/src/org/armedbear/lisp/scripting/lisp/config.lisp

    r11618 r11623  
    3232(in-package :abcl-script)
    3333
    34 (defparameter *abcl-debug* nil)
     34(defparameter *launch-swank-at-startup* nil)
    3535
    3636(defparameter *swank-dir* nil)
     
    4040(defparameter *use-throwing-debugger* t)
    4141
    42 (defparameter *compile-using-temp-files* nil)
     42(defparameter *compile-using-temp-files* t)
     43
     44;(defparameter *compiler-temp-dir* #P".abcl.d/tmp/")
    4345
    4446(defconstant +standard-debugger-hook+ *debugger-hook*)
     
    4951      #'sys::%debugger-hook-function
    5052      +standard-debugger-hook+))
    51   (when *abcl-debug*
     53  (when *launch-swank-at-startup*
    5254    (unless *swank-dir*
    5355      (error "Swank directory not specified, please set *swank-dir*"))
Note: See TracChangeset for help on using the changeset viewer.