Changeset 13190 for trunk/abcl/src/org


Ignore:
Timestamp:
01/30/11 13:17:50 (11 years ago)
Author:
ehuelsmann
Message:

Detect loops in autoloads and requires (and remove some trailing whitespace).

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

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

    r13181 r13190  
    4646    private final Symbol symbol;
    4747
     48    private final static Symbol AUTOLOADS_IN_PROGRESS
     49            = PACKAGE_SYS.addInternalSymbol("*AUTOLOADS-IN-PROGRESS*");
     50    {
     51        AUTOLOADS_IN_PROGRESS.setSymbolValue(NIL);
     52    }
     53
    4854    protected Autoload(Symbol symbol)
    4955    {
     
    134140    }
    135141
     142    private void detectCircularity(LispThread thread) {
     143        SimpleString val = new SimpleString((getFileName() == null)
     144                ? className : getFileName());
     145        LispObject autoloads = AUTOLOADS_IN_PROGRESS.symbolValue(thread);
     146        LispObject list = autoloads;
     147        while (list != NIL) {
     148            if (val.equal(list.car()))
     149                Lisp.error(new SimpleString("Autoloading circularity detected while resolving "
     150                        + symbol.getQualifiedName() + "; autoloads in "
     151                        + "progress: " + autoloads.writeToString()));
     152
     153            list = list.cdr();
     154        }
     155
     156        return;
     157    }
     158
    136159    public void load()
    137160    {
    138161        final LispThread thread = LispThread.currentThread();
     162
     163        detectCircularity(thread);
     164
    139165        final SpecialBindingsMark mark = thread.markSpecialBindings();
    140166        int loadDepth = Fixnum.getValue(_LOAD_DEPTH_.symbolValue());
    141167        thread.bindSpecial(_LOAD_DEPTH_, Fixnum.getInstance(++loadDepth));
     168        thread.pushSpecial(AUTOLOADS_IN_PROGRESS,
     169                new SimpleString((getFileName() == null) ? className : getFileName()));
    142170        try {
    143171            if (_AUTOLOAD_VERBOSE_.symbolValue(thread) != NIL
  • trunk/abcl/src/org/armedbear/lisp/require.lisp

    r12677 r13190  
    3737  t)
    3838
    39 (defun module-provide-system (module) 
     39(defun module-provide-system (module)
    4040  (let ((*readtable* (copy-readtable nil)))
    41     (handler-case 
     41    (handler-case
    4242        (load-system-file (string-downcase (string module)))
    43       (t (e) 
     43      (t (e)
    4444        (unless (and (typep e 'error)
    4545                     (search "Failed to find loadable system file"
    4646                             (format nil "~A" e)))
    47           (format *error-output* "Failed to require  ~A because '~A'~%" 
     47          (format *error-output* "Failed to require  ~A because '~A'~%"
    4848                  module e))
    4949        nil))))
    50    
     50
    5151(defvar *module-provider-functions* nil)
     52(defvar *requires-in-progress* nil)
    5253
    5354(defun require (module-name &optional pathnames)
    5455  (unless (member (string module-name) *modules* :test #'string=)
    55     (let ((saved-modules (copy-list *modules*)))
     56    (unless (member (string module-name) *requires-in-progress*
     57                    :test #'string=)
     58      (error "Circularity detected while requiring ~A; ~
     59              nesting list: ~S." module-name *requires-in-progress*))
     60    (let ((saved-modules (copy-list *modules*))
     61          (*requires-in-progress* (cons (string module-name)
     62                                        *requires-in-progress*)))
    5663      (cond (pathnames
    5764             (unless (listp pathnames) (setf pathnames (list pathnames)))
Note: See TracChangeset for help on using the changeset viewer.