Changeset 15396
- Timestamp:
- 10/10/20 21:43:30 (3 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Lisp.java
r15395 r15396 455 455 { 456 456 return error(new TypeError(datum, expectedType)); 457 } 458 459 public static final LispObject type_error(String message, 460 LispObject datum, 461 LispObject expectedType) { 462 return error(new TypeError(message, datum, expectedType)); 457 463 } 458 464 … … 1922 1928 return ((URLStream)arg).getPathname(); 1923 1929 type_error(arg, list(Symbol.OR, 1924 1925 1926 1930 Symbol.STRING, 1931 Symbol.PATHNAME, Symbol.JAR_PATHNAME, Symbol.URL_PATHNAME, 1932 Symbol.FILE_STREAM, Symbol.JAR_STREAM, Symbol.URL_STREAM)); 1927 1933 // Not reached. 1928 1934 return null; -
trunk/abcl/src/org/armedbear/lisp/Load.java
r15395 r15396 108 108 } 109 109 name.setType(new SimpleString(COMPILE_FILE_TYPE)); 110 name.invalidateNamestring();111 110 result = findLoadableFile(name); 112 111 if (result != null) { … … 158 157 } 159 158 Pathname loadableFile = findLoadableFile(mergedPathname != null ? mergedPathname : pathname); 160 Pathname truename = (Pathname)Symbol.PROBE_FILE.execute(loadableFile); 161 162 if (truename.equals(NIL)) { 159 Pathname truename = (loadableFile != null 160 ? (Pathname)Symbol.PROBE_FILE.execute(loadableFile) 161 : null); 162 163 if (truename == null || truename.equals(NIL)) { 163 164 if (ifDoesNotExist) { 164 165 return error(new FileError("File not found: " + pathname.princToString(), pathname)); … … 298 299 if (bootPath instanceof Pathname) { 299 300 mergedPathname = (Pathname)Symbol.MERGE_PATHNAMES.execute(pathname, bootPath); 301 // So PROBE-FILE won't attempt to merge when 302 // *DEFAULT-PATHNAME-DEFAULTS* is a JAR 303 if (mergedPathname.getDevice().equals(NIL)) { 304 mergedPathname.setDevice(Keyword.UNSPECIFIC); 305 } 300 306 } else { 301 307 mergedPathname = pathname; … … 303 309 URL url = null; 304 310 Pathname loadableFile = findLoadableFile(mergedPathname); 305 truename = (Pathname)Symbol.PROBE_FILE.execute(loadableFile); 311 if (loadableFile == null) { 312 truename = null; 313 } else { 314 truename = (Pathname)Symbol.PROBE_FILE.execute(loadableFile); 315 } 306 316 307 317 final String COMPILE_FILE_TYPE -
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r15395 r15396 320 320 Pathname result = new Pathname(); 321 321 if (s == null) { 322 return (Pathname) simple_error("Refusing to create a PATHNAME for the null reference.");322 return (Pathname)parse_error("Refusing to create a PATHNAME for the null reference."); 323 323 } 324 324 if (s.equals(".") || s.equals("./") … … 347 347 } 348 348 if (shareIndex == -1 || dirIndex == -1) { 349 return Pathname_simple_error("Unsupported UNC path format: \"" + s + '"');349 return (Pathname)parse_error("Unsupported UNC path format: \"" + s + '"'); 350 350 } 351 351 … … 582 582 if (getDevice() == NIL) { 583 583 } else if (getDevice() == Keyword.UNSPECIFIC) { 584 // } else if (isJar()) {585 // LispObject[] jars = ((Cons) getDevice()).copyToArray();586 // StringBuilder prefix = new StringBuilder();587 // for (int i = 0; i < jars.length; i++) {588 // prefix.append("jar:");589 // LispObject component = jars[i];590 // if (!(component instanceof Pathname)) {591 // return null; // If DEVICE is a CONS, it should only contain Pathname592 // }593 // if (! ((Pathname)component).isURL() && i == 0) {594 // sb.append("file:");595 // uriEncoded = true;596 // }597 // Pathname jar = (Pathname) component;598 // String encodedNamestring;599 // if (uriEncoded) {600 // encodedNamestring = uriEncode(jar.getNamestring());601 // } else {602 // encodedNamestring = jar.getNamestring();603 // }604 // sb.append(encodedNamestring);605 // sb.append("!/");606 // }607 // sb = prefix.append(sb);608 584 } else if (getDevice() instanceof AbstractString) { 609 585 sb.append(getDevice().getStringValue()); … … 613 589 } 614 590 } else { 615 Debug.assertTrue(false);591 simple_error("Transitional error in pathname: should be a JAR-PATHNAME", this); 616 592 } 617 593 String directoryNamestring = getDirectoryNamestring(); … … 664 640 } 665 641 } 666 667 // if (isURL()) {668 // LispObject o = Symbol.GETF.execute(getHost(), QUERY, NIL);669 // if (o != NIL) {670 // sb.append("?");671 // sb.append(o.getStringValue());672 // }673 // o = Symbol.GETF.execute(getHost(), FRAGMENT, NIL);674 // if (o != NIL) {675 // sb.append("#");676 // sb.append(o.getStringValue());677 // }678 // }679 642 680 643 if (this instanceof LogicalPathname) { … … 1357 1320 p.setVersion(version); 1358 1321 p.validateDirectory(true); 1322 1323 // TODO: need to check for downcast to PathnameURL as well 1324 // Possibly downcast type to PathnameJar 1325 if (p.getDevice() instanceof Cons) { 1326 PathnameJar result = new PathnameJar(); 1327 ncoerce(p, result); 1328 // sanity check that the pathname has been constructed correctly 1329 result.validateComponents(); 1330 1331 return result; 1332 } 1359 1333 1360 1334 return p; … … 1735 1709 1736 1710 public static final LispObject mergePathnames(final Pathname pathname, 1737 final Pathname defaultPathname,1738 final LispObject defaultVersion) {1711 final Pathname defaultPathname, 1712 final LispObject defaultVersion) { 1739 1713 Pathname result; 1740 1714 Pathname p = Pathname.create(pathname); 1741 1715 Pathname d; 1742 1716 1743 if (pathname instanceof LogicalPathname) { 1744 result = LogicalPathname.create(); 1745 d = Pathname.create(defaultPathname); 1717 if (pathname instanceof LogicalPathname) { 1718 result = LogicalPathname.create(); 1719 d = Pathname.create(defaultPathname); 1720 } else { 1721 if (pathname instanceof PathnameJar 1722 // If the defaults contain a JAR-PATHNAME, and the pathname to 1723 // be be merged is not a JAR-PATHNAME, does not have a specified 1724 // DEVICE, a specified HOST, and doesn't contain a relative 1725 // DIRECTORY, then the result will not be a JAR-PATHNAME 1726 || (defaultPathname instanceof PathnameJar 1727 && !(pathname instanceof PathnameJar) 1728 && pathname.getDevice().equals(NIL) 1729 && !(!pathname.getDirectory().equals(NIL) 1730 && pathname.getDirectory().car().equals(Keyword.ABSOLUTE)))) { 1731 result = PathnameJar.create(); 1732 } else if (pathname instanceof PathnameURL) { 1733 result = PathnameURL.create(); 1746 1734 } else { 1747 if ((pathname instanceof PathnameJar) 1748 || (defaultPathname instanceof PathnameJar)) { 1749 result = PathnameJar.create(); 1735 result = Pathname.create(); 1736 } 1737 1738 if (defaultPathname instanceof LogicalPathname) { 1739 d = LogicalPathname.translateLogicalPathname((LogicalPathname) defaultPathname); 1740 } else { 1741 if (defaultPathname instanceof PathnameJar) { 1742 d = PathnameJar.create(defaultPathname); 1743 } else if (defaultPathname instanceof PathnameURL) { 1744 d = PathnameURL.create(defaultPathname); 1750 1745 } else { 1751 result = Pathname.create(); 1752 } 1753 1754 if (defaultPathname instanceof LogicalPathname) { 1755 d = LogicalPathname.translateLogicalPathname((LogicalPathname) defaultPathname); 1756 } else { 1757 if (defaultPathname instanceof PathnameJar) { 1758 d = PathnameJar.create(defaultPathname); 1759 } else { 1760 d = Pathname.create(defaultPathname); 1761 } 1762 } 1763 } 1746 d = Pathname.create(defaultPathname); 1747 } 1748 } 1749 } 1764 1750 1765 1751 if (pathname.getHost() != NIL) { … … 1772 1758 result.setDevice(p.getDevice()); 1773 1759 } else { 1774 if (d instanceof PathnameJar) { 1775 // If the defaults contain a JAR-PATHNAME, and the pathname 1776 // to be be merged does not have a specified DEVICE, a 1777 // specified HOST, and doesn't contain a relative DIRECTORY, 1778 // then on non-MSDOG, set its device to :UNSPECIFIC. 1760 // If the defaults contain a JAR-PATHNAME, and the pathname 1761 // to be be merged is not a JAR-PATHNAME, does not have a 1762 // specified DEVICE, a specified HOST, and doesn't contain a 1763 // relative DIRECTORY, then on non-MSDOG, set its device to 1764 // :UNSPECIFIC. 1765 if ((d instanceof PathnameJar) 1766 && (result instanceof Pathname)) { 1779 1767 if (pathname.getHost() == NIL 1780 1768 && pathname.getDevice() == NIL … … 1790 1778 result.setDevice(d.getDevice()); 1791 1779 } 1792 } 1793 } 1794 1795 // This part I no longer understand 1780 } else { 1781 result.setDevice(d.getDevice()); 1782 } 1783 } 1784 1785 // Merge the directory of a relative JAR-PATHNAME with the 1786 // default directory. 1796 1787 // if (pathname.isJar()) { 1797 // Cons jars = (Cons)result.getDevice(); 1788 // Pathname root = ((PathnameJar)result).getRootJar(); 1789 1790 1798 1791 // LispObject jar = jars.car; 1799 1792 // if (jar instanceof Pathname) { … … 1813 1806 // result.setDirectory(mergeDirectories(p.getDirectory(), d.getDirectory())); 1814 1807 // } 1815 result.setDirectory(mergeDirectories(p.getDirectory(), d.getDirectory())); 1808 1809 if (pathname.isJar()) { 1810 result.setDirectory(p.getDirectory()); 1811 } else { 1812 result.setDirectory(mergeDirectories(p.getDirectory(), d.getDirectory())); 1813 } 1816 1814 1817 1815 if (pathname.getName() != NIL) { … … 2008 2006 private static final class pf_get_input_stream extends Primitive { 2009 2007 pf_get_input_stream() { 2010 super( "ensure-input-stream", PACKAGE_SYS, true);2008 super(Symbol.GET_INPUT_STREAM, "pathname"); 2011 2009 } 2012 2010 @Override -
trunk/abcl/src/org/armedbear/lisp/PathnameJar.java
r15395 r15396 58 58 protected PathnameJar() {} 59 59 60 public static Pathname create() { 61 return new PathnameJar(); 62 } 63 60 64 public static PathnameJar create(PathnameJar p) { 61 65 return (PathnameJar)PathnameJar.create(p.getNamestring()); … … 197 201 } 198 202 199 static public Pathname create() {200 return new PathnameJar();201 }202 203 static public LispObject create(String s) { 203 204 if (!s.startsWith(JAR_URI_PREFIX)) { … … 238 239 jars = jars.nreverse(); 239 240 result.setDevice(jars); 241 result.validateComponents(); 240 242 return result; 241 243 } 244 245 public LispObject validateComponents() { 246 if (!(getDevice() instanceof Cons)) { 247 return type_error("Invalid DEVICE for JAR-PATHNAME", getDevice(), Symbol.CONS); 248 } 249 250 LispObject jars = getDevice(); 251 while (!jars.car().equals(NIL)) { 252 LispObject jar = jars.car(); 253 if (!((jar instanceof Pathname) 254 || (jar instanceof PathnameURL))) { 255 return type_error("The value in DEVICE component of a JAR-PATHNAME is not of expected type", 256 jar, 257 list(Symbol.OR, 258 Symbol.PATHNAME, Symbol.URL_PATHNAME)); 259 } 260 jars = jars.cdr(); 261 } 262 263 return T; 264 } 265 242 266 243 267 public String getNamestring() { … … 246 270 LispObject jars = getDevice(); 247 271 248 if (jars.equals(NIL) ) { // DESCRIBE ends up here somehow249 // attempt to return some sort of representation250 return super.getNamestring();272 if (jars.equals(NIL) || jars.equals(Keyword.UNSPECIFIC)) { 273 System.out.println("Pathname transitional problem: JAR-PATHNAME has bad PATHNAME-DEVICE"); 274 return null; 251 275 } 252 276 … … 306 330 307 331 LispObject getRootJar() { 308 return getDevice().car(); 332 LispObject jars = getJars(); 333 if (!(jars instanceof Cons)) { 334 System.out.println("Transitional pathname error: PATHNAME-DEVICE is not a Cons cell"); 335 return NIL; 336 } 337 338 return jars.car(); 309 339 } 310 340 … … 324 354 // FIXME implement me 325 355 simple_error("Unimplemented TRUENAME for non-file root jar."); 326 } else { 327 rootJar = (Pathname)Symbol.MERGE_PATHNAMES.execute(rootJar); 328 } 329 330 rootJar = (Pathname)Symbol.TRUENAME.execute(rootJar); 356 } 331 357 332 358 PathnameJar p = new PathnameJar(); -
trunk/abcl/src/org/armedbear/lisp/PathnameURL.java
r15395 r15396 54 54 protected PathnameURL() {} 55 55 56 public static Pathname create() { 57 return new PathnameURL(); 58 } 59 56 60 public static PathnameURL create(PathnameURL p) { 57 61 return (PathnameURL) PathnameURL.create(p.getNamestring()); … … 68 72 public static LispObject create(String s) { 69 73 if (!isValidURL(s)) { 70 error(new SimpleError("Cannot form a PATHNAME-URL from " + s));74 parse_error("Cannot form a PATHNAME-URL from " + s); 71 75 } 72 76 if (s.startsWith("jar:")) { … … 79 83 url = new URL(s); 80 84 } catch (MalformedURLException e) { 81 Debug.assertTrue(false);85 return parse_error("Malformed URL in namestring '" + s + "': " + e.toString()); 82 86 } 83 87 String scheme = url.getProtocol(); … … 87 91 uri = new URI(s); 88 92 } catch (URISyntaxException ex) { 89 error(new SimpleError("Improper URI syntax for "90 91 + ": " + ex.toString()));93 return parse_error("Improper URI syntax for " 94 + "'" + url.toString() + "'" 95 + ": " + ex.toString()); 92 96 } 93 97 … … 98 102 uriPath = uri.getSchemeSpecificPart(); 99 103 if (uriPath == null || uriPath.equals("")) { 100 error(new LispError("The URI has no path: " + uri));104 return parse_error("The namestring URI has no path: " + uri); 101 105 } 102 106 } … … 120 124 uri = url.toURI().normalize(); 121 125 } catch (URISyntaxException e) { 122 error(new LispError("Couldn't form URI from "123 124 + " because: " + e));126 return parse_error("Couldn't form URI from " 127 + "'" + url + "'" 128 + " because: " + e); 125 129 } 126 130 String authority = uri.getAuthority(); -
trunk/abcl/src/org/armedbear/lisp/Symbol.java
r15395 r15396 3093 3093 public static final Symbol _ENABLE_AUTOCOMPILE_ = 3094 3094 PACKAGE_SYS.addExternalSymbol("*ENABLE-AUTOCOMPILE*"); 3095 public static final Symbol ENSURE_INPUT_STREAM =3096 PACKAGE_SYS.addExternalSymbol(" ENSURE-INPUT-STREAM");3095 public static final Symbol GET_INPUT_STREAM = 3096 PACKAGE_SYS.addExternalSymbol("GET-INPUT-STREAM"); 3097 3097 public static final Symbol ENVIRONMENT = 3098 3098 PACKAGE_SYS.addExternalSymbol("ENVIRONMENT"); -
trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp
r15341 r15396 57 57 ;; it would minimally need to check version information. 58 58 (ignore-errors 59 #p" https://abcl.org/releases/1.7.1/abcl.jar")))59 #p"jar:file:https://abcl.org/releases/1.7.1/abcl.jar!/"))) 60 60 61 61 (defun flatten (list) … … 115 115 (let ((jar (some predicate entries))) 116 116 (when jar 117 (return-from find-jar jar)))))) 117 (return-from find-jar 118 (make-pathname :device (list jar)))))))) 118 119 119 120 (defun find-system-jar () -
trunk/abcl/src/org/armedbear/lisp/java.lisp
r15116 r15396 583 583 (defun jinput-stream (pathname) 584 584 "Returns a java.io.InputStream for resource denoted by PATHNAME." 585 (sys: ensure-input-stream pathname))585 (sys:get-input-stream pathname)) 586 586 587 587 (provide "JAVA") -
trunk/abcl/src/org/armedbear/lisp/open.lisp
r14902 r15396 122 122 (error 'file-error 123 123 :pathname pathname 124 :format-control " Bad place fora wild pathname."))124 :format-control "Cannot OPEN a wild pathname.")) 125 125 (when (memq direction '(:output :io)) 126 126 (unless if-exists-given
Note: See TracChangeset
for help on using the changeset viewer.