Changeset 15392


Ignore:
Timestamp:
10/10/20 21:43:22 (3 years ago)
Author:
Mark Evenson
Message:

Debugging Pathname transition with logical pathnames

Added LogicalPathname?.create() and LogicalPathname?()

Solved problems with getting Pathname._makePathname() to return objects of
type LogicalPathname?.

(ignore-errors (asdf:load-system :abcl/test/lisp))
(abcl-test:run-matching "logical")

TODO: refactor the creation of logical pathnames in
Pathname._makePathname() into a new LogicalPathname?._makePathname().

  • * *

Used UNREACHED constant to mark non-local exits

TODO do this consistently

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

Legend:

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

    r15391 r15392  
    4747    = new HashMap();
    4848
     49  // A logical host is represented as the string that names it.
     50  // (defvar *logical-pathname-translations* (make-hash-table :test 'equal))
     51  public static HashTable TRANSLATIONS
     52    = HashTable.newEqualHashTable(LOGICAL_PATHNAME_CHARS.length(), NIL, NIL);
     53  private static final Symbol _TRANSLATIONS_
     54    = exportSpecial("*LOGICAL-PATHNAME-TRANSLATIONS*", PACKAGE_SYS, TRANSLATIONS);
     55
    4956  static public boolean isValidLogicalPathname(String namestring) {
    5057    if (!isValidURL(namestring)) {
    5158      String host = getHostString(namestring);
    5259      if (host != null
    53        && LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(host)) != null) {
     60       && LogicalPathname.TRANSLATIONS.get(new SimpleString(host)) != null) {
    5461        return true;
    5562      }
    5663    }
    5764    return false;
     65  }
     66
     67  protected LogicalPathname() {
     68  }
     69 
     70  // Used in Pathname._makePathname to indicate type for namestring
     71  public static LogicalPathname create() {
     72    return new LogicalPathname();
    5873  }
    5974
    6075  public static LogicalPathname create(String namestring) {
    6176    // parse host out then call create(host, rest);
     77    LogicalPathname result = null;
    6278    if (LogicalPathname.isValidLogicalPathname(namestring)) {
    6379      String h = LogicalPathname.getHostString(namestring);
    64       return LogicalPathname.create(h,
    65                                     namestring.substring(namestring.indexOf(':') + 1));
    66     }
    67     return null;  // Ugh.  I bet this is gonna cause problems. Tighten entrance points
     80      result
     81        = LogicalPathname.create(h, namestring.substring(namestring.indexOf(':') + 1));
     82      return result;
     83    }
     84    error(new FileError("Failed to find a valid logical Pathname host in '" + namestring + "'",
     85                        NIL));  // ??? return NIL as we don't have a
     86                                // PATHNAME.  Maybe signal a different
     87                                // condition?
     88    return (LogicalPathname)UNREACHED;
    6889  }
    6990
     
    7192    // This may be "too late" in the creation chain to be meaningful?
    7293    SimpleString h = new SimpleString(host);
    73     if (LOGICAL_PATHNAME_TRANSLATIONS.get(h) == null) {
     94    if (LogicalPathname.TRANSLATIONS.get(h) == null) {
    7495      // Logical pathnames are only valid when it's host exists
    7596      String message = MessageFormat.format("'{0}' is not a defined logical host", host);
     
    335356                                                h + '"'));
    336357                }
    337                 if (Pathname.LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(h)) != null) {
     358                if (LogicalPathname.TRANSLATIONS.get(new SimpleString(h)) != null) {
    338359                    // A defined logical pathname host.
    339360                    return LogicalPathname.create(h, s.substring(s.indexOf(':') + 1));
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r15391 r15392  
    10771077        return unreadableString(sb.toString());
    10781078    }
    1079     // A logical host is represented as the string that names it.
    1080     // (defvar *logical-pathname-translations* (make-hash-table :test 'equal))
    1081     public static HashTable LOGICAL_PATHNAME_TRANSLATIONS =
    1082       HashTable.newEqualHashTable(64, NIL, NIL);
    1083     private static final Symbol _LOGICAL_PATHNAME_TRANSLATIONS_ =
    1084       exportSpecial("*LOGICAL-PATHNAME-TRANSLATIONS*", PACKAGE_SYS,
    1085       LOGICAL_PATHNAME_TRANSLATIONS);
    10861079
    10871080    public static Pathname parseNamestring(String s) {
     
    11371130        if (!isValidURL(s)) {
    11381131            String h = LogicalPathname.getHostString(s);
    1139             if (h != null && LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(h)) != null) {
     1132            if (h != null
     1133                && LogicalPathname.TRANSLATIONS.get(new SimpleString(h)) != null) {
    11401134                // A defined logical pathname host.
    11411135                return LogicalPathname.create(h, s.substring(s.indexOf(':') + 1));
     
    11641158            s = s.substring(s.indexOf(':') + 1);
    11651159        }
    1166         if (LOGICAL_PATHNAME_TRANSLATIONS.get(host) != null) {
     1160        if (LogicalPathname.TRANSLATIONS.get(host) != null) {
    11671161            // A defined logical pathname host.
    11681162            return LogicalPathname.create(host.getStringValue(), s);
     
    13561350        @Override
    13571351        public LispObject execute(LispObject[] args) {
    1358             return _makePathname(args);
     1352          LispObject result = _makePathname(args);
     1353          return result;
    13591354        }
    13601355    }
     
    13621357    // Used by the #p reader.
    13631358    public static final Pathname makePathname(LispObject args) {
    1364         return _makePathname(args.copyToArray());
     1359      return (Pathname) _makePathname(args.copyToArray());
    13651360    }
    13661361
     
    13781373
    13791374
    1380     static final Pathname _makePathname(LispObject[] args) {
     1375  // ??? changed to return a LispObject, as we wish to return a
     1376  // meaningful Java type (Pathname for files, LogicalPathnames for you know
)
     1377    static final LispObject _makePathname(LispObject[] args) {
    13811378        if (args.length % 2 != 0) {
    13821379            program_error("Odd number of keyword arguments.");
     
    14641461            }
    14651462        }
    1466         final Pathname p;
    1467         final boolean logical;
     1463        Pathname p;
    14681464        LispObject logicalHost = NIL;
    14691465        if (host != NIL) {
     
    14711467                logicalHost = LogicalPathname.canonicalizeStringComponent((AbstractString) host);
    14721468            }
    1473             if (LOGICAL_PATHNAME_TRANSLATIONS.get(logicalHost) == null) {
     1469            if (LogicalPathname.TRANSLATIONS.get(logicalHost) == null) {
    14741470                // Not a defined logical pathname host -- A UNC path
    14751471                //warning(new LispError(host.printObject() + " is not defined as a logical pathname host."));
    14761472                p = Pathname.create();
    1477                 logical = false;
    14781473                p.setHost(host);
    14791474            } else {
    14801475                p = LogicalPathname.create();
    1481                 logical = true;
    14821476                p.setHost(logicalHost);
    14831477            }
     
    14851479        } else {
    14861480            p = Pathname.create();
    1487             logical = false;
    14881481        }
    14891482        if (device != NIL) {
    1490             if (logical) {
     1483            if (p instanceof LogicalPathname) {
    14911484                // "The device component of a logical pathname is always :UNSPECIFIC."
    14921485                if (device != Keyword.UNSPECIFIC) {
     
    14981491        }
    14991492        if (directory != NIL) {
    1500             if (logical) {
     1493            if (p instanceof LogicalPathname) {
    15011494                if (directory.listp()) {
    15021495                    LispObject d = NIL;
     
    15211514        }
    15221515        if (name != NIL) {
    1523             if (logical && name instanceof AbstractString) {
     1516            if (p instanceof LogicalPathname && name instanceof AbstractString) {
    15241517              p.setName(LogicalPathname.canonicalizeStringComponent((AbstractString) name));
    15251518            } else if (name instanceof AbstractString) {
     
    15301523        }
    15311524        if (type != NIL) {
    1532             if (logical && type instanceof AbstractString) {
     1525            if (p instanceof LogicalPathname && type instanceof AbstractString) {
    15331526              p.setType(LogicalPathname.canonicalizeStringComponent((AbstractString) type));
    15341527            } else {
     
    15391532        p.setVersion(version);
    15401533        p.validateDirectory(true);
     1534       
    15411535        return p;
    15421536    }
  • trunk/abcl/src/org/armedbear/lisp/file_error_pathname.java

    r12288 r15392  
    5050    }
    5151
    52     private static final file_error_pathname FILE_ERROR_PATHNAME =
    53         new file_error_pathname();
     52    private static final file_error_pathname FILE_ERROR_PATHNAME
     53      = new file_error_pathname();
    5454}
Note: See TracChangeset for help on using the changeset viewer.