Changeset 15455


Ignore:
Timestamp:
10/29/20 16:54:53 (3 years ago)
Author:
Mark Evenson
Message:

Fix logic for binding *LOAD-TRUENAME*

LOAD from stream creates pathname of appropiate type.

When OPEN is passed a simple filepath *LOAD-TRUENAME* shouldn't
contain a URL-PATHNAME.

TODO how to stop fighting the Java type system with such boilerplate?

TODO go over the bindings of *LOAD-TRUENAME-FASL* as I think this can
be dramatically simplified further.

File:
1 edited

Legend:

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

    r15408 r15455  
    259259
    260260    private static final Symbol FASL_LOADER = PACKAGE_SYS.intern("*FASL-LOADER*");
     261  /** A file with this type in a packed FASL denotes the initial loader */
    261262    static final LispObject COMPILE_FILE_INIT_FASL_TYPE = new SimpleString("_");
    262263
     
    524525            if (!truename.equals(NIL)) {
    525526                if (truename instanceof Pathname) {
    526                     truePathname = Pathname.create((Pathname)truename);
     527                  if (truename instanceof JarPathname) {
     528                    truePathname = new JarPathname();
     529                  } else if (truename instanceof URLPathname) {
     530                    truePathname = new URLPathname();
     531                  } else {
     532                    truePathname = new Pathname();
     533                  }
     534                  truePathname.copyFrom((Pathname)truename);
    527535                } else if (truename instanceof AbstractString) {
    528536                  truePathname = (Pathname)Pathname.create(truename.getStringValue());
     
    530538                    Debug.assertTrue(false);
    531539                }
    532                 String type = truePathname.getType().getStringValue();
    533                 if (type.equals(Lisp._COMPILE_FILE_TYPE_.symbolValue(thread).getStringValue())
    534                     || type.equals(COMPILE_FILE_INIT_FASL_TYPE.toString())) {
     540                if (truePathname.getType().equal(Lisp._COMPILE_FILE_TYPE_.symbolValue(thread))
     541                    || truePathname.getType().equal(COMPILE_FILE_INIT_FASL_TYPE)) {
    535542                    Pathname truenameFasl = Pathname.create(truePathname);
    536543                    thread.bindSpecial(Symbol.LOAD_TRUENAME_FASL, truenameFasl);
    537544                }
    538                 if (truePathname.getType().getStringValue()
    539                     .equals(COMPILE_FILE_INIT_FASL_TYPE.getStringValue())
     545                if (truePathname.getType().equal(COMPILE_FILE_INIT_FASL_TYPE)
    540546                    && truePathname.isJar()) {
    541                     if (truePathname.getDevice().cdr() != NIL ) {
    542                         // We set *LOAD-TRUENAME* to the argument that
    543                         // a user would pass to LOAD.
    544                         Pathname enclosingJar = (Pathname)truePathname.getDevice().cdr().car();
    545                         truePathname.setDevice(new Cons(truePathname.getDevice().car(), NIL));
    546                         truePathname.setHost(NIL);
    547                         truePathname.setDirectory(enclosingJar.getDirectory());
    548                         if (truePathname.getDirectory().car().equals(Keyword.RELATIVE)) {
    549                             truePathname.getDirectory().setCar(Keyword.ABSOLUTE);
    550                         }
    551                         truePathname.setName(enclosingJar.getName());
    552                         truePathname.setType(enclosingJar.getType());
     547                  // We set *LOAD-TRUENAME* to the argument that a
     548                  // user would pass to LOAD.
     549                  truePathname = (Pathname)probe_file.PROBE_FILE.execute(pathname);
     550                  /*
     551                  if (truePathname.getDevice().cdr() != NIL ) {
     552                    Pathname enclosingJar = (Pathname)truePathname.getDevice().cdr().car();
     553                    truePathname.setDevice(new Cons(truePathname.getDevice().car(), NIL));
     554                    truePathname.setHost(NIL);
     555                    truePathname.setDirectory(enclosingJar.getDirectory());
     556                    if (truePathname.getDirectory().car().equals(Keyword.RELATIVE)) {
     557                      truePathname.getDirectory().setCar(Keyword.ABSOLUTE);
     558                    }
     559                    truePathname.setName(enclosingJar.getName());
     560                    truePathname.setType(enclosingJar.getType());
    553561                    } else {
    554562                        // XXX There is something fishy in the asymmetry
     
    556564                        // cases but this currently passes the tests.
    557565                        if (!(truePathname.device.car() instanceof AbstractString)) {
    558                           assert truePathname.getDevice().car() instanceof Pathname;
    559                           Pathname p = Pathname.create((Pathname)truePathname.getDevice().car());
     566                          //                          assert truePathname.getDevice().car() instanceof Pathname;
     567                          //                          Pathname p = Pathname.create((Pathname)truePathname.getDevice().car());
    560568                          truePathname
    561                             = (Pathname) probe_file.PROBE_FILE.execute(p);
     569                            = (Pathname) probe_file.PROBE_FILE.execute(pathname);
    562570                        }
    563571                    }
    564                     thread.bindSpecial(Symbol.LOAD_TRUENAME, truePathname);
     572                  */
     573                  thread.bindSpecial(Symbol.LOAD_TRUENAME, truePathname);
    565574                } else {
    566575                    thread.bindSpecial(Symbol.LOAD_TRUENAME, truename);
Note: See TracChangeset for help on using the changeset viewer.