Changeset 4410
- Timestamp:
- 10/16/03 14:33:01 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/Load.java
r4051 r4410 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: Load.java,v 1.2 1 2003-09-25 15:37:08piso Exp $5 * $Id: Load.java,v 1.22 2003-10-16 14:33:01 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 31 31 public final class Load extends Lisp 32 32 { 33 // ### *modules* 34 private static final Symbol _MODULES_ = 35 exportSpecial("*MODULES*", PACKAGE_CL, NIL); 36 37 // ### *load-verbose* 38 private static final Symbol _LOAD_VERBOSE_ = 39 exportSpecial("*LOAD-VERBOSE*", PACKAGE_CL, T); 40 41 // ### *load-print* 42 private static final Symbol _LOAD_PRINT_ = 43 exportSpecial("*LOAD-PRINT*", PACKAGE_CL, NIL); 44 45 // ### *load-truename* 46 private static final Symbol _LOAD_TRUENAME_ = 47 exportSpecial("*LOAD-TRUENAME*", PACKAGE_CL, NIL); 48 49 // ### *load-depth* 50 // internal symbol 51 private static final Symbol _LOAD_DEPTH_ = 52 internSpecial("*LOAD-DEPTH*", PACKAGE_SYS, new Fixnum(0)); 53 54 /*package*/ static final LispObject load(String filename) 33 public static final LispObject load(String filename) 55 34 throws ConditionThrowable 56 35 { … … 60 39 } 61 40 62 p rivatestatic final LispObject load(final String filename,41 public static final LispObject load(final String filename, 63 42 boolean verbose, boolean print) 64 43 throws ConditionThrowable … … 110 89 throw new ConditionThrowable(new LispError(e.getMessage())); 111 90 } 112 LispObject result = loadFileFromStream(truename, in, verbose, print); 91 LispObject result = 92 loadFileFromStream(truename, in, verbose, print, false); 113 93 try { 114 94 in.close(); … … 120 100 } 121 101 122 /*package*/ static final LispObject _load(final String filename, 123 boolean verbose, boolean print) 102 public static final LispObject _load(String filename) 103 throws ConditionThrowable 104 { 105 return _load(filename, 106 _LOAD_VERBOSE_.symbolValueNoThrow() != NIL, 107 _LOAD_PRINT_.symbolValueNoThrow() != NIL, 108 false); 109 } 110 111 public static final LispObject _load(String filename, boolean auto) 112 throws ConditionThrowable 113 { 114 boolean verbose; 115 if (auto) 116 verbose = _AUTOLOAD_VERBOSE_.symbolValueNoThrow() != NIL; 117 else 118 verbose = _LOAD_VERBOSE_.symbolValueNoThrow() != NIL; 119 return _load(filename, 120 verbose, 121 _LOAD_PRINT_.symbolValueNoThrow() != NIL, 122 auto); 123 } 124 125 public static final LispObject _load(final String filename, 126 boolean verbose, boolean print, 127 boolean auto) 124 128 throws ConditionThrowable 125 129 { … … 150 154 if (in != null) { 151 155 LispObject result = 152 loadFileFromStream(truename, in, verbose, print );156 loadFileFromStream(truename, in, verbose, print, auto); 153 157 try { 154 158 in.close(); … … 165 169 InputStream in, 166 170 boolean verbose, 167 boolean print) 171 boolean print, 172 boolean auto) 168 173 throws ConditionThrowable 169 174 { … … 174 179 int loadDepth = Fixnum.getInt(_LOAD_DEPTH_.symbolValue()); 175 180 thread.bindSpecial(_LOAD_DEPTH_, new Fixnum(++loadDepth)); 176 StringBuffer sb = new StringBuffer(); 177 for (long i = 0; i < loadDepth; i++) 178 sb.append(';'); 179 String semicolons = sb.toString(); 181 final String prefix = getLoadVerbosePrefix(loadDepth); 180 182 try { 181 183 thread.bindSpecial(_LOAD_TRUENAME_, new LispString(truename)); … … 183 185 CharacterOutputStream out = getStandardOutput(); 184 186 out.freshLine(); 185 out.writeString(semicolons); 186 out.writeLine(" Loading " + truename + " ..."); 187 out.writeString(prefix); 188 out.writeString(auto ? " Autoloading " : " Loading "); 189 out.writeString(truename); 190 out.writeLine(" ..."); 187 191 out.flushOutput(); 188 } 189 LispObject result = loadStream(in, print); 190 if (verbose) { 192 LispObject result = loadStream(in, print); 191 193 long elapsed = System.currentTimeMillis() - start; 192 CharacterOutputStream out = getStandardOutput();193 194 out.freshLine(); 194 out.writeString( semicolons);195 out.writeString( " Loaded ");195 out.writeString(prefix); 196 out.writeString(auto ? " Autoloaded " : " Loaded "); 196 197 out.writeString(truename); 197 198 out.writeString(" ("); … … 199 200 out.writeLine(" seconds)"); 200 201 out.flushOutput(); 201 } 202 return result; 202 return result; 203 } else 204 return loadStream(in, print); 203 205 } 204 206 finally { 205 207 thread.setDynamicEnvironment(oldDynEnv); 206 208 } 209 } 210 211 public static String getLoadVerbosePrefix(int loadDepth) 212 { 213 StringBuffer sb = new StringBuffer(";"); 214 for (int i = loadDepth - 1; i-- > 0;) 215 sb.append(' '); 216 return sb.toString(); 207 217 } 208 218 … … 295 305 296 306 // ### %load 297 // FIXME This function should not be exported from COMMON-LISP!298 307 public static final Primitive1 _LOAD = 299 new Primitive1("%load", PACKAGE_SYS, false) { 308 new Primitive1("%load", PACKAGE_SYS, false) 309 { 300 310 public LispObject execute(LispObject arg) throws ConditionThrowable 301 311 { 302 312 return _load(LispString.getValue(arg), 303 313 _LOAD_VERBOSE_.symbolValueNoThrow() != NIL, 304 _LOAD_PRINT_.symbolValueNoThrow() != NIL); 314 _LOAD_PRINT_.symbolValueNoThrow() != NIL, 315 false); 305 316 } 306 317 };
Note: See TracChangeset
for help on using the changeset viewer.