Changeset 15569
- Timestamp:
- 03/19/22 12:50:18 (13 months ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 140 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/AbstractString.java
r13443 r15569 117 117 118 118 public String toString() { 119 120 121 122 123 124 119 int length = length(); 120 StringBuilder sb = new StringBuilder(length); 121 for(int i = 0; i < length; ++i) { 122 sb.append(charAt(i)); 123 } 124 return sb.toString(); 125 125 } 126 126 -
trunk/abcl/src/org/armedbear/lisp/Autoload.java
r15519 r15569 661 661 autoload(Symbol.COPY_LIST, "copy_list"); 662 662 663 664 665 666 667 668 663 autoload(PACKAGE_SYS, "make-fasl-class-loader", "FaslClassLoader", false); 664 autoload(PACKAGE_SYS, "get-fasl-function", "FaslClassLoader", false); 665 666 autoload(PACKAGE_SYS, "make-memory-class-loader", "MemoryClassLoader", false); 667 autoload(PACKAGE_SYS, "put-memory-function", "MemoryClassLoader", false); 668 autoload(PACKAGE_SYS, "get-memory-function", "MemoryClassLoader", false); 669 669 670 670 autoload(Symbol.SET_CHAR, "StringFunctions"); -
trunk/abcl/src/org/armedbear/lisp/ByteArrayOutputStream.java
r15306 r15569 89 89 if (elementType == NIL) { 90 90 return new byte[0]; 91 92 93 91 } else { 92 return byteArrayOutputStream.toByteArray(); 93 } 94 94 } 95 95 -
trunk/abcl/src/org/armedbear/lisp/CharHashMap.java
r12429 r15569 13 13 public class CharHashMap<T> { 14 14 15 16 17 18 15 final public T[] constants; 16 final public T NULL; 17 final static int CACHE_SIZE = 256; 18 final HashMap<Character, T> backing; 19 19 20 20 @SuppressWarnings("unchecked") 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 21 public CharHashMap(Class componentType, T def) { 22 NULL = def; 23 constants = (T[]) Array.newInstance(componentType, CACHE_SIZE); 24 Arrays.fill(constants, NULL); 25 backing = new HashMap<Character, T>(); 26 } 27 28 @Override 29 public Object clone() { 30 CharHashMap<T> n = new CharHashMap<T>(constants.getClass().getComponentType(),NULL); 31 System.arraycopy(constants,0, n.constants,0,CACHE_SIZE); 32 n.backing.putAll(backing); 33 return n; 34 } 35 36 public T get(char key) { 37 if (key<CACHE_SIZE) return constants[key]; 38 T value = backing.get(key); 39 return (value==null) ? NULL:value; 40 } 41 41 42 43 44 45 42 public void clear() { 43 Arrays.fill(constants,NULL); 44 backing.clear(); 45 } 46 46 47 48 49 50 51 52 53 54 47 public T put(char key, T value) { 48 if (key<CACHE_SIZE) { 49 T old = constants[key]; 50 constants[key] = value; 51 return old; 52 } 53 else return backing.put(key, value); 54 } 55 55 56 57 return new Iterator<Character>() { 58 59 60 61 62 63 64 65 66 67 68 69 throw new UnsupportedOperationException(); 70 71 72 73 56 public Iterator<Character> getCharIterator() { 57 return new Iterator<Character>() { 58 final Iterator<Character> carIt = backing.keySet().iterator(); 59 int charNum = -1; 60 public boolean hasNext() { 61 if ( charNum<CACHE_SIZE) return true; 62 return carIt.hasNext(); 63 } 64 public Character next() { 65 if ( charNum<CACHE_SIZE) return (char)++charNum; 66 return carIt.next(); 67 } 68 public void remove() { 69 throw new UnsupportedOperationException(); 70 } 71 72 }; 73 } 74 74 } -
trunk/abcl/src/org/armedbear/lisp/CompiledClosure.java
r14023 r15569 63 63 CompiledClosure result = null; 64 64 try { 65 65 result = (CompiledClosure)super.clone(); 66 66 } catch (CloneNotSupportedException e) { 67 67 } … … 226 226 namestring = arg.getStringValue(); 227 227 if(arg instanceof JavaObject) { 228 229 230 231 232 233 228 try { 229 return loadClassBytes((byte[]) arg.javaInstance(byte[].class)); 230 } catch(Throwable t) { 231 Debug.trace(t); 232 return error(new LispError("Unable to load " + arg.princToString())); 233 } 234 234 } 235 235 return error(new LispError("Unable to load " + arg.princToString())); -
trunk/abcl/src/org/armedbear/lisp/ConcatenatedStream.java
r15138 r15569 115 115 return eofValue; 116 116 } 117 118 119 120 121 122 123 124 117 try 118 { 119 return _charReady() ? readChar(eofError, eofValue) : NIL; 120 } 121 catch (java.io.IOException e) 122 { 123 return error(new StreamError(this, e)); 124 } 125 125 } 126 126 -
trunk/abcl/src/org/armedbear/lisp/Debug.java
r15031 r15569 48 48 Error e = new Error(msg); 49 49 e.printStackTrace(System.err); 50 51 52 53 54 55 56 57 50 51 StringBuffer buffer = new StringBuffer(); 52 final String CR = "\n"; 53 buffer.append(msg).append(CR); 54 StackTraceElement[] stack = e.getStackTrace(); 55 for (int i = 0; i < stack.length; i++) { 56 buffer.append(stack[i].toString()).append(CR); 57 } 58 58 throw new Error(buffer.toString()); 59 59 } -
trunk/abcl/src/org/armedbear/lisp/FaslClassLoader.java
r15406 r15569 65 65 66 66 if (c == null && checkPreCompiledClassLoader) { 67 68 69 67 c = findPrecompiledClassOrNull(name); 68 // Oh, we have to return here so we don't become the owning class loader? 69 if (c != null) 70 70 return c; 71 71 } … … 89 89 try { 90 90 if (checkPreCompiledClassLoader) { 91 92 93 return c;91 Class<?> c = findPrecompiledClassOrNull(name); 92 if (c != null) 93 return c; 94 94 } 95 95 byte[] b = getFunctionClassBytes(name); … … 156 156 private static final Primitive GET_FASL_FUNCTION = new pf_get_fasl_function(); 157 157 private static final class pf_get_fasl_function extends Primitive { 158 158 pf_get_fasl_function() { 159 159 super("get-fasl-function", PACKAGE_SYS, false, "loader function-number"); 160 160 } … … 163 163 public LispObject execute(LispObject loader, LispObject fnNumber) { 164 164 FaslClassLoader l = (FaslClassLoader) loader.javaInstance(FaslClassLoader.class); 165 165 return l.loadFunction(fnNumber.intValue()); 166 166 } 167 167 }; -
trunk/abcl/src/org/armedbear/lisp/FaslReadtable.java
r13187 r15569 44 44 protected void initialize() 45 45 { 46 46 Byte[] syntax = this.syntax.constants; 47 47 syntax[9] = SYNTAX_TYPE_WHITESPACE; // tab 48 48 syntax[10] = SYNTAX_TYPE_WHITESPACE; // linefeed -
trunk/abcl/src/org/armedbear/lisp/FileStream.java
r15447 r15569 88 88 Debug.assertTrue(mode != null); 89 89 RandomAccessFile raf = new RandomAccessFile(file, mode); 90 90 91 91 // ifExists is ignored unless we have an output stream. 92 92 if (isOutputStream) { … … 103 103 setExternalFormat(format); 104 104 105 106 105 // don't touch raf directly after passing it to racf. 106 // the state will become inconsistent if you do that. 107 107 racf = new RandomAccessCharacterFile(raf, encoding); 108 108 … … 112 112 isCharacterStream = true; 113 113 bytesPerUnit = 1; 114 115 116 117 118 119 114 if (isInputStream) { 115 initAsCharacterInputStream(racf.getReader()); 116 } 117 if (isOutputStream) { 118 initAsCharacterOutputStream(racf.getWriter()); 119 } 120 120 } else { 121 121 isBinaryStream = true; 122 122 int width = Fixnum.getValue(elementType.cadr()); 123 123 bytesPerUnit = width / 8; 124 125 126 127 128 129 124 if (isInputStream) { 125 initAsBinaryInputStream(racf.getInputStream()); 126 } 127 if (isOutputStream) { 128 initAsBinaryOutputStream(racf.getOutputStream()); 129 } 130 130 } 131 131 } … … 205 205 { 206 206 try { 207 208 209 210 211 207 if (isInputStream) { 208 racf.position(racf.length()); 209 } else { 210 streamNotInputStream(); 211 } 212 212 } 213 213 catch (IOException e) { -
trunk/abcl/src/org/armedbear/lisp/Function.java
r15365 r15569 51 51 52 52 protected Function() { 53 54 55 53 LispObject loadTruename = Symbol.LOAD_TRUENAME.symbolValueNoThrow(); 54 LispObject loadTruenameFasl = Symbol.LOAD_TRUENAME_FASL.symbolValueNoThrow(); 55 loadedFrom = loadTruenameFasl != null ? loadTruenameFasl : (loadTruename != null ? loadTruename : NIL); 56 56 } 57 57 … … 63 63 public Function(String name, String arglist) 64 64 { 65 65 this(); 66 66 if(arglist != null) 67 67 setLambdaList(new SimpleString(arglist)); … … 76 76 public Function(Symbol symbol) 77 77 { 78 78 this(symbol, null, null); 79 79 } 80 80 81 81 public Function(Symbol symbol, String arglist) 82 82 { 83 83 this(symbol, arglist, null); 84 84 } 85 85 86 86 public Function(Symbol symbol, String arglist, String docstring) 87 87 { 88 88 this(); 89 89 symbol.setSymbolFunction(this); 90 90 if (cold) … … 117 117 String arglist, String docstring) 118 118 { 119 119 this(); 120 120 if (arglist instanceof String) 121 121 setLambdaList(new SimpleString(arglist)); … … 138 138 public Function(LispObject name) 139 139 { 140 140 this(); 141 141 setLambdaName(name); 142 142 } … … 144 144 public Function(LispObject name, LispObject lambdaList) 145 145 { 146 146 this(); 147 147 setLambdaName(name); 148 148 setLambdaList(lambdaList); … … 226 226 public static final Primitive FUNCTION_CLASS_BYTES = new pf_function_class_bytes(); 227 227 public static final class pf_function_class_bytes extends Primitive { 228 229 228 public pf_function_class_bytes() { 229 super("function-class-bytes", PACKAGE_SYS, false, "function"); 230 230 } 231 231 @Override … … 233 233 if (arg instanceof Function) { 234 234 return ((Function) arg).getClassBytes(); 235 235 } 236 236 return type_error(arg, Symbol.FUNCTION); 237 237 } -
trunk/abcl/src/org/armedbear/lisp/HashTableFunctions.java
r14466 r15569 87 87 LispObject rehashSize, 88 88 LispObject rehashThreshold, 89 89 LispObject weakness) 90 90 { 91 91 final int n = Fixnum.getValue(size); 92 92 if (test == FUNCTION_EQL || test == NIL) 93 93 return WeakHashTable.newEqlHashTable(n, rehashSize, 94 94 rehashThreshold, weakness); 95 95 if (test == FUNCTION_EQ) 96 96 return WeakHashTable.newEqHashTable(n, rehashSize, … … 98 98 if (test == FUNCTION_EQUAL) 99 99 return WeakHashTable.newEqualHashTable(n, rehashSize, 100 100 rehashThreshold, weakness); 101 101 if (test == FUNCTION_EQUALP) 102 102 return WeakHashTable.newEqualpHashTable(n, rehashSize, 103 103 rehashThreshold, weakness); 104 104 return error(new LispError("Unsupported test for MAKE-HASH-TABLE: " + 105 105 test.princToString())); -
trunk/abcl/src/org/armedbear/lisp/JProxy.java
r15521 r15569 131 131 } 132 132 133 134 135 136 137 138 133 //NEW IMPLEMENTATION by Alessio Stalla 134 135 /** 136 * A weak map associating each proxy instance with a "Lisp-this" object. 137 */ 138 static final Map<Object, LispObject> proxyMap = new WeakHashMap<Object, LispObject>(); 139 139 140 140 public static class LispInvocationHandler implements InvocationHandler { 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 } 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 141 142 private Function function; 143 private static Method hashCodeMethod; 144 private static Method equalsMethod; 145 private static Method toStringMethod; 146 147 static { 148 try { 149 hashCodeMethod = Object.class.getMethod("hashCode", new Class[] {}); 150 equalsMethod = Object.class.getMethod("equals", new Class[] { Object.class }); 151 toStringMethod = Object.class.getMethod("toString", new Class[] {}); 152 } catch (Exception e) { 153 throw new Error("Something got horribly wrong - can't get a method from Object.class", e); 154 } 155 } 156 157 public LispInvocationHandler(Function function) { 158 this.function = function; 159 } 160 161 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 162 if(hashCodeMethod.equals(method)) { 163 return System.identityHashCode(proxy); 164 } 165 if(equalsMethod.equals(method)) { 166 return proxy == args[0]; 167 } 168 if(toStringMethod.equals(method)) { 169 return proxy.getClass().getName() + '@' + Integer.toHexString(proxy.hashCode()); 170 } 171 172 if(args == null) { 173 args = new Object[0]; 174 } 175 LispObject lispArgs = NIL; 176 synchronized(proxyMap) { 177 lispArgs = lispArgs.push(toLispObject(proxyMap.get(proxy))); 178 } 179 lispArgs = lispArgs.push(new SimpleString(method.getName())); 180 for(int i = 0; i < args.length; i++) { 181 lispArgs = lispArgs.push(toLispObject(args[i])); 182 } 183 Object retVal = 184 LispThread.currentThread().execute 185 (Symbol.APPLY, function, lispArgs.reverse()).javaInstance(); 186 //(function.execute(lispArgs)).javaInstance(); 187 /* DOES NOT WORK due to autoboxing! 188 if(retVal != null && !method.getReturnType().isAssignableFrom(retVal.getClass())) { 189 return error(new TypeError(new JavaObject(retVal), new JavaObject(method.getReturnType()))); 190 }*/ 191 return retVal; 192 } 193 } 194 195 private static final Primitive _JMAKE_INVOCATION_HANDLER = 196 new Primitive("%jmake-invocation-handler", PACKAGE_JAVA, false, 197 "function") { 198 199 public LispObject execute(LispObject[] args) { 200 int length = args.length; 201 if (length != 1) { 202 return error(new WrongNumberOfArgumentsException(this, 1)); 203 } 204 if(!(args[0] instanceof Function)) { 205 return type_error(args[0], Symbol.FUNCTION); 206 } 207 return new JavaObject(new LispInvocationHandler((Function) args[0])); 208 } 209 }; 210 210 211 211 private static final Primitive _JMAKE_PROXY = 212 213 214 215 216 217 218 219 220 221 222 223 224 225 212 new Primitive("%jmake-proxy", PACKAGE_JAVA, false, 213 "interfaces invocation-handler") { 214 215 public LispObject execute(final LispObject[] args) { 216 int length = args.length; 217 if (length != 3) { 218 return error(new WrongNumberOfArgumentsException(this, 3)); 219 } 220 if(!(args[0] instanceof Cons)) { 221 return type_error(args[0], Symbol.CONS); 222 } 223 Class[] ifaces = new Class[args[0].length()]; 224 LispObject ifList = args[0]; 225 for(int i = 0; i < ifaces.length; i++) { 226 226 ifaces[i] = (Class) ifList.car().javaInstance(Class.class); 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 227 ifList = ifList.cdr(); 228 } 229 InvocationHandler invocationHandler = (InvocationHandler) ((JavaObject) args[1]).javaInstance(InvocationHandler.class); 230 Object proxy = Proxy.newProxyInstance( 231 JavaClassLoader.getCurrentClassLoader(), 232 ifaces, 233 invocationHandler); 234 synchronized(proxyMap) { 235 proxyMap.put(proxy, args[2]); 236 } 237 return new JavaObject(proxy); 238 } 239 }; 240 241 static LispObject toLispObject(Object obj) { 242 return (obj instanceof LispObject) ? (LispObject) obj : new JavaObject(obj); 243 } 244 245 245 } -
trunk/abcl/src/org/armedbear/lisp/JarPathname.java
r15493 r15569 387 387 Pathname withoutDevice = new Pathname(); 388 388 withoutDevice 389 389 .copyFrom(this) 390 390 .setDevice(NIL); 391 391 … … 425 425 426 426 public static LispObject truename(Pathname pathname, 427 427 boolean errorIfDoesNotExist) { 428 428 if (!(pathname instanceof JarPathname)) { 429 429 return URLPathname.truename(pathname, errorIfDoesNotExist); … … 452 452 LispObject rootJarTruename = Pathname.truename(rootJar, errorIfDoesNotExist); 453 453 if (rootJarTruename.equals(NIL)) { 454 454 return Pathname.doTruenameExit(rootJar, errorIfDoesNotExist); 455 455 } 456 456 LispObject otherJars = p.getJars().cdr(); -
trunk/abcl/src/org/armedbear/lisp/Java.java
r15511 r15569 151 151 public LispObject execute(LispObject arg) 152 152 { 153 153 return JavaObject.getInstance(javaClass(arg, JavaClassLoader.getCurrentClassLoader())); 154 154 } 155 155 … … 157 157 public LispObject execute(LispObject className, LispObject classLoader) 158 158 { 159 160 159 ClassLoader loader = (ClassLoader) classLoader.javaInstance(ClassLoader.class); 160 return JavaObject.getInstance(javaClass(className, loader)); 161 161 } 162 162 }; … … 588 588 try { 589 589 Constructor constructor; 590 591 592 593 594 595 596 597 598 599 600 601 590 if(classRef instanceof AbstractString) { 591 constructor = findConstructor(javaClass(classRef), args); 592 } else { 593 Object object = JavaObject.getObject(classRef); 594 if(object instanceof Constructor) { 595 constructor = (Constructor) object; 596 } else if(object instanceof Class<?>) { 597 constructor = findConstructor((Class<?>) object, args); 598 } else { 599 return error(new LispError(classRef.princToString() + " is neither a Constructor nor a Class")); 600 } 601 } 602 602 Class[] argTypes = constructor.getParameterTypes(); 603 603 Object[] initargs = new Object[args.length-1]; … … 936 936 method = (Method) JavaObject.getObject(methodArg); 937 937 Class<?>[] argTypes = (Class<?>[])method.getParameterTypes(); 938 939 940 938 if(argTypes.length != args.length - 2) { 939 return error(new WrongNumberOfArgumentsException("Wrong number of arguments for " + method + ": expected " + argTypes.length + ", got " + (args.length - 2))); 940 } 941 941 methodArgs = new Object[argTypes.length]; 942 942 for (int i = 2; i < args.length; i++) { … … 953 953 // Possible for static member classes: see #229 954 954 if (Modifier.isPublic(method.getModifiers())) { 955 955 method.setAccessible(true); 956 956 } 957 957 } 958 958 return JavaObject.getInstance(method.invoke(instance, methodArgs), 959 959 translate, … … 982 982 983 983 private static Object[] translateMethodArguments(LispObject[] args) { 984 984 return translateMethodArguments(args, 0); 985 985 } 986 986 987 987 private static Object[] translateMethodArguments(LispObject[] args, int offs) { 988 988 int argCount = args.length - offs; 989 989 Object[] javaArgs = new Object[argCount]; 990 990 for (int i = 0; i < argCount; ++i) { … … 998 998 } 999 999 } 1000 1000 return javaArgs; 1001 1001 } 1002 1002 … … 1033 1033 if(intendedClass != actualClass) { 1034 1034 method = findMethod(actualClass, methodName, methodArgs); 1035 1036 1037 1038 1039 1035 if (method != null) { 1036 if (isMethodCallableOnInstance(actualClass, method)) { 1037 return method; 1038 } 1039 } 1040 1040 } 1041 1041 } … … 1045 1045 private static boolean isMethodCallableOnInstance(Class instance, Method method) { 1046 1046 if (Modifier.isPublic(method.getModifiers())) { 1047 1047 return true; 1048 1048 } 1049 1049 if (instance.isMemberClass()) { 1050 1050 return isMethodCallableOnInstance(instance.getEnclosingClass(), method); 1051 1051 } 1052 1052 return false; … … 1087 1087 } 1088 1088 if (result == null) { 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1089 StringBuilder sb = new StringBuilder(c.getSimpleName()); 1090 sb.append('('); 1091 boolean first = true; 1092 for(Object o : javaArgs) { 1093 if(first) { 1094 first = false; 1095 } else { 1096 sb.append(", "); 1097 } 1098 if(o != null) { 1099 sb.append(o.getClass().getName()); 1100 } else { 1101 sb.append("<null>"); 1102 } 1103 } 1104 sb.append(')'); 1105 1105 throw new NoSuchMethodException(sb.toString()); 1106 1106 } … … 1203 1203 1204 1204 public static Class<?> maybeBoxClass(Class<?> clazz) { 1205 1206 1207 1208 1209 1205 if(clazz.isPrimitive()) { 1206 return getBoxedClass(clazz); 1207 } else { 1208 return clazz; 1209 } 1210 1210 } 1211 1211 … … 1352 1352 public LispObject execute(LispObject javaObject, LispObject intendedClass) 1353 1353 { 1354 1355 1356 1357 1358 1354 Object o = javaObject.javaInstance(); 1355 Class<?> c = javaClass(intendedClass); 1356 try { 1357 return JavaObject.getInstance(o, c); 1358 } catch(ClassCastException e) { 1359 1359 return type_error(javaObject, new SimpleString(c.getName())); 1360 1360 } 1361 1361 } 1362 1362 }; … … 1391 1391 1392 1392 private static Class classForName(String className) { 1393 1393 return classForName(className, JavaClassLoader.getPersistentInstance()); 1394 1394 } 1395 1395 … … 1431 1431 1432 1432 private static Class javaClass(LispObject obj) { 1433 1433 return javaClass(obj, JavaClassLoader.getCurrentClassLoader()); 1434 1434 } 1435 1435 … … 1457 1457 // Not a primitive Java type. 1458 1458 Class c; 1459 1459 c = classForName(s, classLoader); 1460 1460 if (c == null) 1461 1461 error(new LispError(s + " does not designate a Java class.")); -
trunk/abcl/src/org/armedbear/lisp/JavaBeans.java
r14326 r15569 51 51 pf__jget_property_value() 52 52 { 53 53 super("%jget-property-value", PACKAGE_JAVA, false, 54 54 "java-object property-name"); 55 55 } 56 56 57 57 @Override 58 58 public LispObject execute(LispObject javaObject, LispObject propertyName) { 59 60 61 62 63 64 65 66 67 68 69 70 59 try { 60 Object obj = javaObject.javaInstance(); 61 PropertyDescriptor pd = getPropertyDescriptor(obj, propertyName); 62 Object value = pd.getReadMethod().invoke(obj); 63 if(value instanceof LispObject) { 64 return (LispObject) value; 65 } else if(value != null) { 66 return JavaObject.getInstance(value, true); 67 } else { 68 return NIL; 69 } 70 } catch (Exception e) { 71 71 return error(new JavaException(e)); 72 72 } 73 73 } 74 74 }; … … 82 82 pf__jset_property_value() 83 83 { 84 84 super("%jset-property-value", PACKAGE_JAVA, false, 85 85 "java-object property-name value"); 86 86 } 87 87 88 88 @Override 89 89 public LispObject execute(LispObject javaObject, LispObject propertyName, LispObject value) { 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 90 Object obj = null; 91 try { 92 obj = javaObject.javaInstance(); 93 PropertyDescriptor pd = getPropertyDescriptor(obj, propertyName); 94 Object jValue; 95 //TODO maybe we should do this in javaInstance(Class) 96 if(value instanceof JavaObject) { 97 jValue = value.javaInstance(); 98 } else { 99 if(Boolean.TYPE.equals(pd.getPropertyType()) || 100 Boolean.class.equals(pd.getPropertyType())) { 101 jValue = value != NIL; 102 } else { 103 jValue = value != NIL ? value.javaInstance() : null; 104 } 105 } 106 pd.getWriteMethod().invoke(obj, jValue); 107 return value; 108 } catch (Exception e) { 109 109 return error(new JavaException(e)); 110 110 } 111 111 } 112 112 }; … … 116 116 BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); 117 117 for(PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { 118 119 120 118 if(pd.getName().equals(prop)) { 119 return pd; 120 } 121 121 } 122 122 error(new LispError("Property " + prop + " not found in " + obj)); -
trunk/abcl/src/org/armedbear/lisp/JavaObject.java
r15363 r15569 371 371 = new StringBuilder(c.isArray() ? "jarray" : c.getName()); 372 372 sb.append(' '); 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 373 try { 374 String ts = obj.toString(); 375 int length = -1; 376 LispObject stringLength = _JAVA_OBJECT_TO_STRING_LENGTH.symbolValueNoThrow(); 377 if (stringLength instanceof Fixnum) { 378 length = Fixnum.getValue(stringLength); 379 } 380 if (length < 0) { 381 sb.append(ts); 382 } else if (ts.length() > length) { 383 // use '....' to not confuse user with PPRINT conventions 384 sb.append(ts.substring(0, length)).append("...."); 385 } else { 386 sb.append(ts); 387 } 388 s = sb.toString(); 389 } catch (Exception e) { 390 return serror(new JavaException(e)); 391 } 392 392 } else { 393 393 s = "null"; … … 414 414 for (int i = 0; i < length; i++) { 415 415 parts = parts 416 416 .push(new Cons(new SimpleString(String.valueOf(i)), 417 417 JavaObject.getInstance(Array.get(obj, i)))); 418 418 } … … 609 609 = new pf_describe_java_object(); 610 610 @DocString(name="describe-java-object", 611 612 611 args="object stream", 612 doc="Print a human friendly description of Java OBJECT to STREAM.") 613 613 private static final class pf_describe_java_object extends Primitive 614 614 { … … 619 619 public LispObject execute(LispObject first, LispObject second) { 620 620 if (!(first instanceof JavaObject)) 621 621 return type_error(first, Symbol.JAVA_OBJECT); 622 622 final Stream stream = checkStream(second); 623 623 final JavaObject javaObject = (JavaObject) first; -
trunk/abcl/src/org/armedbear/lisp/JavaStackFrame.java
r14953 r15569 61 61 final String JAVA_STACK_FRAME = "JAVA-STACK-FRAME"; 62 62 return unreadableString(JAVA_STACK_FRAME + " " 63 63 + toLispString().toString()); 64 64 } 65 65 … … 122 122 LispObject result = NIL; 123 123 result = result.push(new Cons("CLASS", 124 124 new SimpleString(javaFrame.getClassName()))); 125 125 result = result.push(new Cons("METHOD", 126 126 new SimpleString(javaFrame.getMethodName()))); 127 127 result = result.push(new Cons("FILE", 128 128 new SimpleString(javaFrame.getFileName()))); 129 129 result = result.push(new Cons("LINE", 130 130 Fixnum.getInstance(javaFrame.getLineNumber()))); 131 131 result = result.push(new Cons("NATIVE-METHOD", 132 132 LispObject.getInstance(javaFrame.isNativeMethod()))); 133 133 return result.nreverse(); 134 134 } -
trunk/abcl/src/org/armedbear/lisp/LispCharacter.java
r15228 r15569 270 270 sb.append("No-break_space"); 271 271 break; 272 273 272 default: 273 if (name!=null) 274 274 sb.append(name); 275 275 else 276 276 sb.append(value); 277 277 break; -
trunk/abcl/src/org/armedbear/lisp/LispObject.java
r15027 r15569 137 137 138 138 return error(new LispError("The value " + princToString() + 139 139 " is not of class " + c.getName())); 140 140 } 141 141 -
trunk/abcl/src/org/armedbear/lisp/LispStackFrame.java
r15552 r15569 106 106 LispObject lambdaName = ((Operator)operator).getLambdaName(); 107 107 if (lambdaName != null && lambdaName != Lisp.NIL) 108 108 return result.push(lambdaName); 109 109 } 110 110 return result.push(operator); … … 161 161 result = result.push(new Cons("ARGS", args)); 162 162 } 163 163 164 164 return result.nreverse(); 165 165 } -
trunk/abcl/src/org/armedbear/lisp/Load.java
r15458 r15569 206 206 truename = (Pathname)initTruename; 207 207 } 208 208 209 209 InputStream in = truename.getInputStream(); 210 210 Debug.assertTrue(in != null); … … 370 370 final SpecialBindingsMark mark = thread.markSpecialBindings(); 371 371 thread.bindSpecial(_WARN_ON_REDEFINITION_, NIL); 372 372 thread.bindSpecial(FASL_LOADER, NIL); 373 373 try { 374 374 Stream stream = new Stream(Symbol.SYSTEM_STREAM, in, Symbol.CHARACTER); … … 636 636 if (obj == EOF) 637 637 break; 638 638 result = eval(obj, env, thread); 639 639 if (print) { 640 640 Stream out = -
trunk/abcl/src/org/armedbear/lisp/Package.java
r15036 r15569 929 929 930 930 public Object readResolve() throws java.io.ObjectStreamException { 931 932 933 934 935 936 931 Package pkg = findPackage(name); 932 if(pkg != null) { 933 return pkg; 934 } else { 935 return error(new PackageError(name + " is not the name of a package.", new SimpleString(name))); 936 } 937 937 } 938 938 } -
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r15492 r15569 1747 1747 } else { 1748 1748 if (d instanceof JarPathname 1749 1749 && p instanceof JarPathname) { 1750 1750 result.setDevice(d.getDevice()); 1751 1751 } else { … … 1767 1767 } 1768 1768 } else { 1769 1770 1771 1772 1773 1769 if (p.isLocalFile()) { 1770 result.setDevice(d.getDevice()); 1771 } else { 1772 result.setDevice(p.getDevice()); 1773 } 1774 1774 } 1775 1775 } -
trunk/abcl/src/org/armedbear/lisp/ProgramError.java
r15001 r15569 51 51 setFormatControl(initArgs.car().getStringValue()); 52 52 setFormatArguments(initArgs.cdr()); 53 53 } 54 54 55 55 } -
trunk/abcl/src/org/armedbear/lisp/Ratio.java
r15548 r15569 526 526 return new DoubleFloat(doubleValue()).truncate(obj); 527 527 BigInteger n, d; 528 529 528 try { 529 if (obj instanceof Fixnum) { 530 530 n = ((Fixnum)obj).getBigInteger(); 531 531 d = BigInteger.ONE; 532 532 } else if (obj instanceof Bignum) { 533 533 n = ((Bignum)obj).value; 534 534 d = BigInteger.ONE; 535 535 } else if (obj instanceof Ratio) { 536 536 n = ((Ratio)obj).numerator(); 537 537 d = ((Ratio)obj).denominator(); 538 538 } else { 539 539 return type_error(obj, Symbol.NUMBER); 540 541 542 543 544 545 546 547 548 540 } 541 // Invert and multiply. 542 BigInteger num = numerator.multiply(d); 543 BigInteger den = denominator.multiply(n); 544 BigInteger quotient = num.divide(den); 545 // Multiply quotient by divisor. 546 LispObject product = number(quotient.multiply(n), d); 547 // Subtract to get remainder. 548 LispObject remainder = subtract(product); 549 549 return LispThread.currentThread().setValues(number(quotient), remainder); 550 550 } -
trunk/abcl/src/org/armedbear/lisp/Readtable.java
r14448 r15569 310 310 protected static class DispatchTable 311 311 { 312 312 protected final CharHashMap<LispObject> functions; 313 313 314 314 public DispatchTable() … … 535 535 toReadtable.syntax.put(toChar, fromReadtable.syntax.get(fromChar)); 536 536 toReadtable.readerMacroFunctions.put(toChar, 537 537 fromReadtable.readerMacroFunctions.get(fromChar)); 538 538 // "If the character is a dispatching macro character, its entire 539 539 // dispatch table of reader macro functions is copied." 540 540 DispatchTable found = fromReadtable.dispatchTables.get(fromChar); 541 541 if (found!=null) 542 542 toReadtable.dispatchTables.put(toChar, new DispatchTable(found)); 543 543 else 544 544 // Don't leave behind dispatch tables when fromChar 545 545 // doesn't have one 546 546 toReadtable.dispatchTables.put(toChar, null); 547 547 return T; 548 548 } -
trunk/abcl/src/org/armedbear/lisp/RuntimeClass.java
r12513 r15569 57 57 if (length < 3 || length % 2 != 1) 58 58 return error(new WrongNumberOfArgumentsException(this)); 59 60 59 RuntimeClass rc = new RuntimeClass(); 60 String className = args[0].getStringValue(); 61 61 for (int i = 1; i < length; i = i+2) { 62 62 String methodName = args[i].getStringValue(); 63 63 rc.addLispMethod(methodName, (Function)args[i+1]); 64 64 } 65 65 classes.put(className, rc); 66 66 return T; 67 67 } 68 68 }; … … 80 80 { 81 81 82 83 84 85 86 82 String cn = className.getStringValue(); 83 String mn = methodName.getStringValue(); 84 Function def = (Function) methodDef; 85 RuntimeClass rc = null; 86 if (classes.containsKey(cn)) { 87 87 rc = (RuntimeClass) classes.get(cn); 88 88 rc.addLispMethod(mn, def); 89 89 return T; 90 91 90 } 91 else { 92 92 error(new LispError("undefined Java class: " + cn)); 93 93 return NIL; 94 94 } 95 95 } 96 96 }; … … 106 106 { 107 107 String cn = className.getStringValue(); 108 109 108 String pn = cn.substring(0,cn.lastIndexOf('.')); 109 byte[] cb = (byte[]) classBytes.javaInstance(); 110 110 try { 111 111 JavaClassLoader loader = JavaClassLoader.getPersistentInstance(pn); -
trunk/abcl/src/org/armedbear/lisp/SocketStream.java
r13442 r15569 44 44 public SocketStream(Socket socket, Stream in, Stream out) 45 45 { 46 46 super(in, out); 47 47 this.socket = socket; 48 48 } … … 73 73 public LispObject close(LispObject abort) 74 74 { 75 76 77 78 79 80 81 75 try { 76 socket.close(); 77 setOpen(false); 78 return T; 79 } catch (Exception e) { 80 return error(new LispError(e.getMessage())); 81 } 82 82 } 83 83 } -
trunk/abcl/src/org/armedbear/lisp/SpecialOperators.java
r15554 r15569 126 126 final LispThread thread = LispThread.currentThread(); 127 127 final SpecialBindingsMark mark = thread.markSpecialBindings(); 128 129 128 Environment ext = new Environment(env); 129 thread.envStack.push(ext); 130 130 try { 131 131 LispObject varList = checkList(args.car()); … … 152 152 if (sequential) { 153 153 ext = new Environment(ext); 154 154 thread.envStack.push(ext); 155 155 bindArg(specials, symbol, value, ext, thread); 156 156 } else … … 173 173 finally { 174 174 thread.resetSpecialBindings(mark); 175 175 while (thread.envStack.pop() != ext) {}; 176 176 } 177 177 } … … 260 260 final Environment ext = new Environment(env); 261 261 try { 262 263 264 265 266 262 thread.envStack.push(ext); 263 args = ext.processDeclarations(args); 264 return progn(args, ext, thread); 265 } 266 finally { 267 267 while (thread.envStack.pop() != ext) {}; 268 268 } -
trunk/abcl/src/org/armedbear/lisp/StructureObject.java
r15025 r15569 155 155 156 156 protected int getSlotIndex(LispObject slotName) { 157 158 159 160 161 162 163 164 165 166 157 LispObject effectiveSlots = structureClass.getSlotDefinitions(); 158 LispObject[] effectiveSlotsArray = effectiveSlots.copyToArray(); 159 for (int i = 0; i < slots.length; i++) { 160 SimpleVector slotDefinition = (SimpleVector) effectiveSlotsArray[i]; 161 LispObject candidateSlotName = slotDefinition.AREF(1); 162 if(slotName == candidateSlotName) { 163 return i; 164 } 165 } 166 return -1; 167 167 } 168 168 … … 175 175 value = slots[index]; 176 176 } else { 177 177 value = UNBOUND_VALUE; 178 178 value = Symbol.SLOT_UNBOUND.execute(structureClass, this, slotName); 179 179 LispThread.currentThread()._values = null; … … 185 185 final int index = getSlotIndex(slotName); 186 186 if (index >= 0) { 187 187 slots[index] = newValue; 188 188 } else { 189 190 191 192 193 194 195 189 LispObject[] args = new LispObject[5]; 190 args[0] = structureClass; 191 args[1] = this; 192 args[2] = slotName; 193 args[3] = Symbol.SETF; 194 args[4] = newValue; 195 Symbol.SLOT_MISSING.execute(args); 196 196 } 197 197 } -
trunk/abcl/src/org/armedbear/lisp/Symbol.java
r15542 r15569 939 939 940 940 public Object readResolve() throws java.io.ObjectStreamException { 941 942 943 944 945 946 941 if(pkg instanceof Package) { 942 Symbol s = ((Package) pkg).intern(name.getStringValue()); 943 return s; 944 } else { 945 return this; 946 } 947 947 } 948 948 -
trunk/abcl/src/org/armedbear/lisp/URLPathname.java
r15456 r15569 109 109 } catch (URISyntaxException ex) { 110 110 parse_error("Improper URI syntax for " 111 112 113 111 + "'" + url.toString() + "'" 112 + ": " + ex.toString()); 113 return (URLPathname)UNREACHED; 114 114 } 115 115 … … 121 121 if (uriPath == null || uriPath.equals("")) { 122 122 parse_error("The namestring URI has no path: " + uri); 123 123 return (URLPathname)UNREACHED; 124 124 } 125 125 } … … 146 146 } catch (URISyntaxException e) { 147 147 parse_error("Couldn't form URI from " 148 149 148 + "'" + url + "'" 149 + " because: " + e); 150 150 return (URLPathname)UNREACHED; 151 151 } … … 263 263 // <https://docs.microsoft.com/en-us/archive/blogs/ie/file-uris-in-windows> 264 264 if (Utilities.isPlatformWindows 265 265 && getDevice() instanceof SimpleString) { 266 266 sb.append("/") 267 267 .append(getDevice().getStringValue()) 268 268 .append(":"); 269 269 } 270 270 String directoryNamestring = getDirectoryNamestring(); … … 330 330 if (!directory.equals("")) { 331 331 if (Utilities.isPlatformWindows 332 333 332 && getDevice() instanceof SimpleString) { 333 path = getDevice().getStringValue() + ":" + directory + file; 334 334 } else { 335 335 path = directory + file; 336 336 } 337 337 } else { -
trunk/abcl/src/org/armedbear/lisp/WeakReference.java
r13440 r15569 83 83 @Override 84 84 public LispObject execute(LispObject obj) { 85 85 return new WeakReference(obj); 86 86 } 87 87 }; … … 106 106 107 107 LispObject value = ((WeakReference)obj).ref.get(); 108 108 return LispThread.currentThread().setValues(value == null ? NIL : value, 109 109 value == null ? NIL : T); 110 110 } -
trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java
r15001 r15569 54 54 super(StandardClass.PROGRAM_ERROR); 55 55 this.operator = operator; 56 57 56 this.expectedMinArgs = expectedMin; 57 this.expectedMaxArgs = expectedMax; 58 58 this.actualArgs = args; 59 59 setFormatControl(getMessage().replaceAll("~","~~")); … … 77 77 public WrongNumberOfArgumentsException(String message) { 78 78 super(StandardClass.PROGRAM_ERROR); 79 80 81 82 79 if(message == null) { 80 throw new NullPointerException("message can not be null"); 81 } 82 this.message = message; 83 83 setFormatControl(getMessage().replaceAll("~","~~")); 84 84 setFormatArguments(NIL); … … 88 88 public String getMessage() 89 89 { 90 91 92 90 if(message != null) { 91 return message; 92 } 93 93 StringBuilder sb = 94 94 new StringBuilder("Wrong number of arguments for " 95 95 + operator.princToString()); 96 97 96 if(expectedMinArgs >= 0 || expectedMaxArgs >= 0) { 97 sb.append("; "); 98 98 99 99 if (expectedMinArgs == expectedMaxArgs) { … … 110 110 } 111 111 112 113 112 sb.append(" expected"); 113 } 114 114 if (actualArgs != null) { 115 115 sb.append(" -- provided: "); -
trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp
r15503 r15569 61 61 (defun flatten (list) 62 62 (labels ((rflatten (list accumluator) 63 64 65 66 67 63 (dolist (element list) 64 (if (listp element) 65 (setf accumluator (rflatten element accumluator)) 66 (push element accumluator))) 67 accumluator)) 68 68 (let (result) 69 69 (reverse (rflatten list result))))) … … 72 72 "Return a list of the directories as pathnames referenced in the JVM classpath." 73 73 (let* ((separator (java:jstatic "getProperty" "java.lang.System" "path.separator")) 74 75 76 77 74 (paths (coerce (java:jcall "split" 75 (java:jstatic "getProperty" "java.lang.System" 76 "java.class.path") 77 separator) 78 78 'list)) 79 79 (p (coerce paths 'list))) … … 92 92 (cond 93 93 ((java:jinstance-of-p entry "java.net.URLClassLoader") ;; java1.[678] 94 95 94 (dolist (url (coerce (java:jcall "getURLs" entry) 95 'list)) 96 96 (let ((p (directory-of (pathname (java:jcall "toString" url))))) 97 98 97 (when (probe-file p) 98 (pushnew p result :test 'equal))))) 99 99 ((pathnamep entry) 100 100 (pushnew (directory-of entry) result :test 'equal)) 101 101 ((and (stringp entry) 102 102 (probe-file (pathname (directory-of entry)))) 103 103 (pushnew (pathname (directory-of entry)) result :test 'equal)) 104 104 (t … … 112 112 (dolist (d (enumerate-resource-directories)) 113 113 (let ((entries (directory (make-pathname :defaults d 114 115 114 :name "*" 115 :type "jar")))) 116 116 (let ((jar (some predicate entries))) 117 118 117 (when (and jar (probe-file jar)) 118 (return-from find-jar 119 119 (make-pathname :device (list (probe-file jar))))))))) 120 120 -
trunk/abcl/src/org/armedbear/lisp/adjoin.lisp
r11695 r15569 36 36 (error "test and test-not both supplied")) 37 37 (if (let ((key-val (sys::apply-key key item))) 38 39 40 38 (if notp 39 (member key-val list :test-not test-not :key key) 40 (member key-val list :test test :key key))) 41 41 list 42 42 (cons item list))) -
trunk/abcl/src/org/armedbear/lisp/and.lisp
r11391 r15569 36 36 (defmacro and (&rest forms) 37 37 (cond ((endp forms) t) 38 39 40 41 42 38 ((endp (rest forms)) (first forms)) 39 (t 40 `(if ,(first forms) 41 (and ,@(rest forms)) 42 nil)))) -
trunk/abcl/src/org/armedbear/lisp/arrays.lisp
r15307 r15569 69 69 (defun sbit (simple-bit-array &rest subscripts) 70 70 (row-major-aref simple-bit-array 71 71 (%array-row-major-index simple-bit-array subscripts))) 72 72 73 73 (defsetf row-major-aref aset) -
trunk/abcl/src/org/armedbear/lisp/assert.lisp
r11391 r15569 43 43 ,@(mapcar #'(lambda (place) 44 44 `(setf ,place (assert-prompt ',place ,place))) 45 45 places))) 46 46 47 47 (defun assert-error (assertion places datum &rest arguments) … … 62 62 (defun assert-prompt (name value) 63 63 (cond ((y-or-n-p "The old value of ~S is ~S.~%Do you want to supply a new value? " 64 64 name value) 65 65 (fresh-line *query-io*) 66 67 68 69 70 71 66 (format *query-io* "Type a form to be evaluated:~%") 67 (flet ((read-it () (eval (read *query-io*)))) 68 (if (symbolp name) ;help user debug lexical variables 69 (progv (list name) (list value) (read-it)) 70 (read-it)))) 71 (t value))) -
trunk/abcl/src/org/armedbear/lisp/assoc.lisp
r11391 r15569 38 38 ((endp alist)) 39 39 (if (car alist) 40 40 (if ,test-guy (return (car alist)))))) 41 41 42 42 (defun assoc (item alist &key key test test-not) 43 43 (cond (test 44 45 46 47 48 49 50 51 52 53 54 55 44 (if key 45 (assoc-guts (funcall test item (funcall key (caar alist)))) 46 (assoc-guts (funcall test item (caar alist))))) 47 (test-not 48 (if key 49 (assoc-guts (not (funcall test-not item 50 (funcall key (caar alist))))) 51 (assoc-guts (not (funcall test-not item (caar alist)))))) 52 (t 53 (if key 54 (assoc-guts (eql item (funcall key (caar alist)))) 55 (assoc-guts (eql item (caar alist))))))) 56 56 57 57 (defun assoc-if (predicate alist &key key) … … 67 67 (defun rassoc (item alist &key key test test-not) 68 68 (cond (test 69 70 71 72 73 74 75 76 77 78 79 80 69 (if key 70 (assoc-guts (funcall test item (funcall key (cdar alist)))) 71 (assoc-guts (funcall test item (cdar alist))))) 72 (test-not 73 (if key 74 (assoc-guts (not (funcall test-not item 75 (funcall key (cdar alist))))) 76 (assoc-guts (not (funcall test-not item (cdar alist)))))) 77 (t 78 (if key 79 (assoc-guts (eql item (funcall key (cdar alist)))) 80 (assoc-guts (eql item (cdar alist))))))) 81 81 82 82 (defun rassoc-if (predicate alist &key key) … … 98 98 ((and (endp x) (endp y)) alist) 99 99 (if (or (endp x) (endp y)) 100 100 (error "the lists of keys and data are of unequal length")) 101 101 (setq alist (acons (car x) (car y) alist)))) 102 102 … … 107 107 alist 108 108 (let ((result 109 110 111 112 113 114 115 116 117 118 119 120 121 122 109 (cons (if (atom (car alist)) 110 (car alist) 111 (cons (caar alist) (cdar alist))) 112 nil))) 113 (do ((x (cdr alist) (cdr x)) 114 (splice result 115 (cdr (rplacd splice 116 (cons 117 (if (atom (car x)) 118 (car x) 119 (cons (caar x) (cdar x))) 120 nil))))) 121 ((endp x))) 122 result))) -
trunk/abcl/src/org/armedbear/lisp/backquote.lisp
r14591 r15569 48 48 ;;; 49 49 ;;; |`,|: [a] => a 50 ;;; NIL: [a] => a 51 ;;; T: [a] => a 50 ;;; NIL: [a] => a ;the NIL flag is used only when a is NIL 51 ;;; T: [a] => a ;the T flag is used when a is self-evaluating 52 52 ;;; QUOTE: [a] => (QUOTE a) 53 53 ;;; APPEND: [a] => (APPEND . a) … … 84 84 (let ((*backquote-count* (1+ *backquote-count*))) 85 85 (multiple-value-bind (flag thing) 86 86 (backquotify stream (read stream t nil t)) 87 87 (when (eq flag *bq-at-flag*) 88 88 (%reader-error stream ",@ after backquote in ~S" thing)) 89 89 (when (eq flag *bq-dot-flag*) 90 90 (%reader-error stream ",. after backquote in ~S" thing)) 91 91 (backquotify-1 flag thing)))) 92 92 … … 98 98 (%reader-error stream "Comma not inside a backquote.")) 99 99 (let ((c (read-char stream)) 100 100 (*backquote-count* (1- *backquote-count*))) 101 101 (cond ((char= c #\@) 102 103 104 105 106 102 (cons *bq-at-flag* (read stream t nil t))) 103 ((char= c #\.) 104 (cons *bq-dot-flag* (read stream t nil t))) 105 (t (unread-char c stream) 106 (cons *bq-comma-flag* (read stream t nil t)))))) 107 107 108 108 ;;; … … 116 116 (defun backquotify (stream code) 117 117 (cond ((atom code) 118 119 118 (cond ((null code) (values nil nil)) 119 ((or (consp code) 120 120 (symbolp code)) 121 121 ;; Keywords are self-evaluating. Install after packages. 122 122 (values 'quote code)) 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 123 (t (values t code)))) 124 ((or (eq (car code) *bq-at-flag*) 125 (eq (car code) *bq-dot-flag*)) 126 (values (car code) (cdr code))) 127 ((eq (car code) *bq-comma-flag*) 128 (comma (cdr code))) 129 ((eq (car code) *bq-vector-flag*) 130 (multiple-value-bind (dflag d) (backquotify stream (cdr code)) 131 (values 'vector (backquotify-1 dflag d)))) 132 (t (multiple-value-bind (aflag a) (backquotify stream (car code)) 133 (multiple-value-bind (dflag d) (backquotify stream (cdr code)) 134 (when (eq dflag *bq-at-flag*) 135 ;; Get the errors later. 136 (%reader-error stream ",@ after dot in ~S" code)) 137 (when (eq dflag *bq-dot-flag*) 138 (%reader-error stream ",. after dot in ~S" code)) 139 (cond 140 ((eq aflag *bq-at-flag*) 141 (if (null dflag) 142 (if (expandable-backq-expression-p a) 143 143 (values 'append (list a)) 144 144 (comma a)) 145 146 147 148 149 150 151 145 (values 'append 146 (cond ((eq dflag 'append) 147 (cons a d )) 148 (t (list a (backquotify-1 dflag d))))))) 149 ((eq aflag *bq-dot-flag*) 150 (if (null dflag) 151 (if (expandable-backq-expression-p a) 152 152 (values 'nconc (list a)) 153 153 (comma a)) 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 154 (values 'nconc 155 (cond ((eq dflag 'nconc) 156 (cons a d)) 157 (t (list a (backquotify-1 dflag d))))))) 158 ((null dflag) 159 (if (memq aflag '(quote t nil)) 160 (values 'quote (list a)) 161 (values 'list (list (backquotify-1 aflag a))))) 162 ((memq dflag '(quote t)) 163 (if (memq aflag '(quote t nil)) 164 (values 'quote (cons a d )) 165 (values 'list* (list (backquotify-1 aflag a) 166 (backquotify-1 dflag d))))) 167 (t (setq a (backquotify-1 aflag a)) 168 (if (memq dflag '(list list*)) 169 (values dflag (cons a d)) 170 (values 'list* 171 (list a (backquotify-1 dflag d))))))))))) 172 172 173 173 ;;; This handles the <hair> cases. 174 174 (defun comma (code) 175 175 (cond ((atom code) 176 177 178 179 180 181 176 (cond ((null code) 177 (values nil nil)) 178 ((or (numberp code) (eq code t)) 179 (values t code)) 180 (t (values *bq-comma-flag* code)))) 181 ((and (eq (car code) 'quote) 182 182 (not (expandable-backq-expression-p (cadr code)))) 183 183 (values (car code) (cadr code))) 184 185 186 187 188 184 ((memq (car code) '(append list list* nconc)) 185 (values (car code) (cdr code))) 186 ((eq (car code) 'cons) 187 (values 'list* (cdr code))) 188 (t (values *bq-comma-flag* code)))) 189 189 190 190 ;;; This handles table 1. 191 191 (defun backquotify-1 (flag thing) 192 192 (cond ((or (eq flag *bq-comma-flag*) 193 194 195 196 197 193 (memq flag '(t nil))) 194 thing) 195 ((eq flag 'quote) 196 (list 'quote thing)) 197 ((eq flag 'list*) 198 198 (cond ((and (null (cddr thing)) 199 199 (not (expandable-backq-expression-p (cadr thing)))) 200 201 200 (cons 'backq-cons thing)) 201 ((expandable-backq-expression-p (car (last thing))) 202 202 (list 'backq-append 203 203 (cons 'backq-list (butlast thing)) … … 205 205 (car (last thing)))) 206 206 (t 207 208 209 210 211 212 213 214 207 (cons 'backq-list* thing)))) 208 ((eq flag 'vector) 209 (list 'backq-vector thing)) 210 (t (cons (ecase flag 211 ((list) 'backq-list) 212 ((append) 'backq-append) 213 ((nconc) 'backq-nconc)) 214 thing)))) 215 215 216 216 ;;;; magic BACKQ- versions of builtin functions … … 236 236 (defun %reader-error (stream control &rest args) 237 237 (error 'reader-error 238 239 240 238 :stream stream 239 :format-control control 240 :format-arguments args)) -
trunk/abcl/src/org/armedbear/lisp/bit-array-ops.lisp
r11391 r15569 37 37 (declare (type (array bit) array1 array2)) 38 38 (and (= (array-rank array1) 39 39 (array-rank array2)) 40 40 (dotimes (index (array-rank array1) t) 41 42 43 41 (when (/= (array-dimension array1 index) 42 (array-dimension array2 index)) 43 (return nil))))) 44 44 45 45 (defun require-same-dimensions (array1 array2) … … 53 53 ((t) bit-array-1) 54 54 ((nil) (make-array (array-dimensions bit-array-1) 55 56 55 :element-type 'bit 56 :initial-element 0)) 57 57 (t 58 58 (require-same-dimensions bit-array-1 result-bit-array) -
trunk/abcl/src/org/armedbear/lisp/butlast.lisp
r11391 r15569 39 39 (unless (null list) 40 40 (let ((length (do ((list list (cdr list)) 41 41 (i 0 (1+ i))) 42 42 ((atom list) (1- i))))) 43 43 (unless (< length n) 44 45 46 47 44 (do* ((top (cdr list) (cdr top)) 45 (result (list (car list))) 46 (splice result) 47 (count length (1- count))) 48 48 ((= count n) result) 49 49 (setq splice (cdr (rplacd splice (list (car top)))))))))) 50 50 51 51 (defun nbutlast (list &optional (n 1)) … … 54 54 (unless (null list) 55 55 (let ((length (do ((list list (cdr list)) 56 56 (i 0 (1+ i))) 57 57 ((atom list) (1- i))))) 58 58 (unless (< length n) 59 60 61 59 (do ((1st (cdr list) (cdr 1st)) 60 (2nd list 1st) 61 (count length (1- count))) 62 62 ((= count n) 63 63 (rplacd 2nd ()) -
trunk/abcl/src/org/armedbear/lisp/case.lisp
r11391 r15569 38 38 (or (zerop n) ; since anything can be considered an improper list of length 0 39 39 (and (consp x) 40 40 (list-of-length-at-least-p (cdr x) (1- n))))) 41 41 42 42 (defun case-body-error (name keyform keyform-value expected-type keys) … … 66 66 (if proceedp 67 67 (let ((block (gensym)) 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 68 (again (gensym))) 69 `(let ((,keyform-value ,keyform)) 70 (block ,block 71 (tagbody 72 ,again 73 (return-from 74 ,block 75 (cond ,@(nreverse clauses) 76 (t 77 (setf ,keyform-value 78 (setf ,keyform 79 (case-body-error 80 ',name ',keyform ,keyform-value 81 ',expected-type ',keys))) 82 (go ,again)))))))) 83 83 `(let ((,keyform-value ,keyform)) 84 85 86 87 ;; 88 ;; 89 ;; 90 ;; 91 ;; 92 93 94 84 (cond 85 ,@(nreverse clauses) 86 ,@(if errorp 87 ;; `((t (error 'case-failure 88 ;; :name ',name 89 ;; :datum ,keyform-value 90 ;; :expected-type ',expected-type 91 ;; :possibilities ',keys)))))))) 92 `((t (error 'type-error 93 :datum ,keyform-value 94 :expected-type ',expected-type)))))))) 95 95 96 96 ;;; CASE-BODY returns code for all the standard "case" macros. NAME is … … 109 109 (warn "no clauses in ~S" name)) 110 110 (let ((keyform-value (gensym)) 111 112 111 (clauses ()) 112 (keys ())) 113 113 (do* ((cases cases (cdr cases)) 114 115 114 (case (car cases) (car cases))) 115 ((null cases) nil) 116 116 (unless (list-of-length-at-least-p case 1) 117 117 (error "~S -- bad clause in ~S" case name)) 118 118 (destructuring-bind (keyoid &rest forms) case 119 120 121 122 123 119 (cond ((and (memq keyoid '(t otherwise)) 120 (null (cdr cases))) 121 (if errorp 122 (progn 123 (style-warn "~@<Treating bare ~A in ~A as introducing a ~ 124 124 normal-clause, not an otherwise-clause~@:>" 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 125 keyoid name) 126 (push keyoid keys) 127 (push `((,test ,keyform-value ',keyoid) nil ,@forms) 128 clauses)) 129 (push `(t nil ,@forms) clauses))) 130 ((and multi-p (listp keyoid)) 131 (setf keys (append keyoid keys)) 132 (push `((or ,@(mapcar (lambda (key) 133 `(,test ,keyform-value ',key)) 134 keyoid)) 135 nil 136 ,@forms) 137 clauses)) 138 (t 139 (push keyoid keys) 140 (push `((,test ,keyform-value ',keyoid) 141 nil 142 ,@forms) 143 clauses))))) 144 144 (case-body-aux name keyform keyform-value clauses keys errorp proceedp 145 145 `(,(if multi-p 'member 'or) ,@keys)))) 146 146 147 147 (defmacro case (keyform &body cases) -
trunk/abcl/src/org/armedbear/lisp/chars.lisp
r11391 r15569 36 36 (defun char/= (character &rest more-characters) 37 37 (do* ((head character (car list)) 38 38 (list more-characters (cdr list))) 39 39 ((atom list) T) 40 40 (unless (do* ((l list (cdr l))) ;inner loop returns T 41 ((atom l) T); iff head /= rest.42 41 ((atom l) T) ; iff head /= rest. 42 (if (eql head (car l)) (return nil))) 43 43 (return nil)))) 44 44 45 45 (defun char> (character &rest more-characters) 46 46 (do* ((c character (car list)) 47 47 (list more-characters (cdr list))) 48 48 ((atom list) T) 49 49 (unless (> (char-int c) 50 50 (char-int (car list))) 51 51 (return nil)))) 52 52 53 53 (defun char>= (character &rest more-characters) 54 54 (do* ((c character (car list)) 55 55 (list more-characters (cdr list))) 56 56 ((atom list) T) 57 57 (unless (>= (char-int c) 58 58 (char-int (car list))) 59 59 (return nil)))) 60 60 … … 65 65 (defun char-not-equal (character &rest more-characters) 66 66 (do* ((head character (car list)) 67 67 (list more-characters (cdr list))) 68 68 ((atom list) T) 69 69 (unless (do* ((l list (cdr l))) 70 71 72 73 70 ((atom l) T) 71 (if (= (equal-char-code head) 72 (equal-char-code (car l))) 73 (return nil))) 74 74 (return nil)))) -
trunk/abcl/src/org/armedbear/lisp/check-type.lisp
r11391 r15569 51 51 :format-arguments 52 52 (list place place-value type-string)) 53 54 55 53 (make-condition 'simple-type-error 54 :datum place-value :expected-type type 55 :format-control 56 56 "The value of ~S is ~S, which is not of type ~S." 57 58 57 :format-arguments 58 (list place place-value type))))) 59 59 (restart-case (error cond) 60 60 (store-value (value) -
trunk/abcl/src/org/armedbear/lisp/clos.lisp
r15564 r15569 2200 2200 (subseq gf-lambda-list (position '&aux gf-lambda-list))))))) 2201 2201 (if gf 2202 2203 2204 2205 2206 2207 2202 (restart-case 2203 (check-method-lambda-list name method-lambda-list 2204 (generic-function-lambda-list gf)) 2205 (unbind-and-try-again () :report (lambda(s) (format s "Undefine generic function #'~a and continue" name)) 2206 (fmakunbound name) 2207 (setf gf (ensure-generic-function name :lambda-list gf-lambda-list)))) 2208 2208 (setf gf (ensure-generic-function name :lambda-list gf-lambda-list))) 2209 2209 (let ((method … … 2901 2901 (setf specializers-form `(list ,@(nreverse specializers-form))) 2902 2902 `(progn 2903 2903 (sys::record-source-information-for-type ',function-name '(:method ,function-name ,qualifiers ,specializers)) 2904 2904 (ensure-method ',function-name 2905 2905 :lambda-list ',lambda-list … … 3048 3048 (sys::record-source-information-for-type ',function-name '(:generic-function ,function-name)) 3049 3049 ,@(loop for method-form in rest 3050 3051 3052 3053 3054 3050 when (eq (car method-form) :method) 3051 collect 3052 (multiple-value-bind (function-name qualifiers lambda-list specializers documentation declarations body) 3053 (mop::parse-defmethod `(,function-name ,@(rest method-form))) 3054 `(sys::record-source-information-for-type ',function-name '(:method ,function-name ,qualifiers ,specializers)))) 3055 3055 (let ((gf (symbol-function ',temp-sym))) 3056 3056 ;; FIXME (rudi 2012-07-08): fset gets the source location info … … 3322 3322 (let ((methods '())) 3323 3323 (dolist (method (generic-function-methods gf)) 3324 3325 3326 3327 3328 3329 3330 3324 (multiple-value-bind (applicable knownp) 3325 (method-applicable-using-classes-p method classes) 3326 (cond (applicable 3327 (push method methods)) 3328 ((not knownp) 3329 (return-from compute-applicable-methods-using-classes 3330 (values nil nil)))))) 3331 3331 (values (sort-methods methods gf classes) 3332 3332 t)))) 3333 3333 3334 3334 … … 3807 3807 3808 3808 (defmethod update-instance-for-redefined-class ((instance standard-object) 3809 3810 3811 3812 3809 added-slots 3810 discarded-slots 3811 property-list 3812 &rest initargs) 3813 3813 (check-initargs (list #'update-instance-for-redefined-class) 3814 3814 (list* instance added-slots discarded-slots … … 4144 4144 (when (eq (car option) :report) 4145 4145 (setf report (cadr option)) 4146 4146 (setf options (delete option options :test #'equal)) 4147 4147 (return))) 4148 4148 (typecase report 4149 4149 (null 4150 4150 `(progn 4151 4151 (sys::record-source-information-for-type ',name :condition) 4152 4152 (defclass ,name ,parent-types ,slot-specs ,@options) 4153 4153 ',name)) 4154 4154 (string 4155 4155 `(progn 4156 4156 (sys::record-source-information-for-type ',name :condition) 4157 4157 (defclass ,name ,parent-types ,slot-specs ,@options) 4158 4158 (defmethod print-object ((condition ,name) stream) … … 4163 4163 (t 4164 4164 `(progn 4165 4165 (sys::record-source-information-for-type ',name :condition) 4166 4166 (defclass ,name ,parent-types ,slot-specs ,@options) 4167 4167 (defmethod print-object ((condition ,name) stream) … … 4560 4560 (autoload-ref-p (second function-name)))) 4561 4561 (fmakunbound function-name) 4562 4563 4564 4565 4562 (progn 4563 (cerror "Redefine as generic function" "~A already names an ordinary function, macro, or special operator." function-name) 4564 (fmakunbound function-name) 4565 ))) 4566 4566 (apply (if (eq generic-function-class +the-standard-generic-function-class+) 4567 4567 #'make-instance-standard-generic-function -
trunk/abcl/src/org/armedbear/lisp/collect.lisp
r11391 r15569 59 59 `(progn 60 60 ,@(mapcar #'(lambda (form) 61 62 63 64 65 66 67 61 `(let ((,n-res (cons ,form nil))) 62 (cond (,n-tail 63 (setf (cdr ,n-tail) ,n-res) 64 (setq ,n-tail ,n-res)) 65 (t 66 (setq ,n-tail ,n-res ,n-value ,n-res))))) 67 forms) 68 68 ,n-value))) 69 69 … … 94 94 95 95 (let ((macros ()) 96 96 (binds ())) 97 97 (dolist (spec collections) 98 98 (unless (<= 1 (length spec) 3) 99 99 (error "Malformed collection specifier: ~S." spec)) 100 100 (let ((n-value (gensym)) 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 101 (name (first spec)) 102 (default (second spec)) 103 (kind (or (third spec) 'collect))) 104 (push `(,n-value ,default) binds) 105 (if (eq kind 'collect) 106 (let ((n-tail (gensym))) 107 (if default 108 (push `(,n-tail (last ,n-value)) binds) 109 (push n-tail binds)) 110 (push `(,name (&rest args) 111 (collect-list-expander ',n-value ',n-tail args)) 112 macros)) 113 (push `(,name (&rest args) 114 (collect-normal-expander ',n-value ',kind args)) 115 macros)))) 116 116 `(macrolet ,macros (let* ,(nreverse binds) ,@body)))) 117 117 -
trunk/abcl/src/org/armedbear/lisp/compile-file.lisp
r15484 r15569 61 61 (let ((name 62 62 (sanitize-class-name 63 63 (%format nil "~A_~D" (pathname-name output-file-pathname) n)))) 64 64 (merge-pathnames (make-pathname :name name :type *compile-file-class-extension*) 65 65 output-file-pathname))) … … 70 70 (declare (type fixnum i)) 71 71 (when (or (char= (char name i) #\-) 72 73 72 (char= (char name i) #\.) 73 (char= (char name i) #\Space)) 74 74 (setf (char name i) #\_))) 75 75 name)) … … 315 315 (declare (ignore stream compile-time-too)) 316 316 (let* ((name (second form)) 317 317 (type (third form))) 318 318 (when (quoted-form-p name) (setq name (second name))) 319 319 (when (quoted-form-p type) (setq type (second type))) … … 321 321 `(sys:put ',sym 'sys::source 322 322 (cl:cons '(,type ,(namestring *source*) ,*source-position*) 323 324 325 323 (cl:get ',sym 'sys::source nil)))))) 324 325 326 326 (declaim (ftype (function (t t t) t) process-toplevel-mop.ensure-method)) 327 327 (defun process-toplevel-mop.ensure-method (form stream compile-time-too) … … 407 407 (let ((defpackage-name (and (eq (car form) 'defpackage) (intern (string (second form)) :keyword))) ) 408 408 (setf form 409 409 (precompiler:precompile-form form nil *compile-file-environment*)) 410 410 (eval form) 411 411 ;; Force package prefix to be used when dumping form. … … 418 418 ;; it is a string by now) (if it is a defpackage) 419 419 (if defpackage-name 420 421 422 423 420 `(sys:put ,defpackage-name 'sys::source 421 (cl:cons '(:package ,(namestring *source*) ,*source-position*) 422 (cl:get ,defpackage-name 'sys::source nil))) 423 nil))) 424 424 425 425 (declaim (ftype (function (t t t) t) process-toplevel-declare)) … … 486 486 (let ((*compile-print* nil)) 487 487 (process-toplevel-form (macroexpand-1 form *compile-file-environment*) 488 488 stream compile-time-too)) 489 489 (let* ((sym (if (consp (second form)) (second (second form)) (second form)))) 490 490 (when (eq (car form) 'defgeneric) 491 491 `(progn 492 493 492 (sys:put ',sym 'sys::source 493 (cl:cons '((:generic-function ,(second form)) 494 494 ,(namestring *source*) ,*source-position*) 495 495 (cl:get ',sym 'sys::source nil))) 496 497 498 499 500 496 ,@(loop for method-form in (cdddr form) 497 when (eq (car method-form) :method) 498 collect 499 (multiple-value-bind (function-name qualifiers lambda-list specializers documentation declarations body) 500 (mop::parse-defmethod `(,(second form) ,@(rest method-form))) 501 501 ;;; FIXME: style points for refactoring double backquote to "normal" form 502 503 502 `(sys:put ',sym 'sys::source 503 (cl:cons `((:method ,',sym ,',qualifiers ,',specializers) 504 504 ,,(namestring *source*) ,,*source-position*) 505 505 (cl:get ',sym 'sys::source nil))))))))) 506 506 507 507 … … 548 548 (sys::get-fasl-function *fasl-loader* 549 549 ,saved-class-number))) 550 551 552 550 `(progn 551 (sys:put ',name 'sys::source 552 (cl:cons '(:macro ,(namestring *source*) ,*source-position*) 553 553 (cl:get ',name 'sys::source nil))) 554 555 556 557 558 559 560 554 (sys:fset ',name 555 (sys:make-macro ',name 556 (sys::get-fasl-function *fasl-loader* 557 ,saved-class-number)) 558 ,*source-position* 559 ',(third form) 560 ,(%documentation name 'cl:function))))))) 561 561 562 562 (declaim (ftype (function (t t t) t) process-toplevel-defun)) … … 598 598 (when compile-time-too 599 599 (eval form)) 600 601 602 603 600 (let ((sym (if (consp name) (second name) name))) 601 (setf form 602 `(progn 603 (sys:put ',sym 'sys::source 604 604 (cl:cons '((:function ,name) 605 605 ,(namestring *source*) ,*source-position*) 606 (cl:get ',sym 'sys::source nil))) 607 606 (cl:get ',sym 'sys::source nil))) 607 (sys:fset ',name 608 608 (sys::get-fasl-function *fasl-loader* 609 609 ,saved-class-number) … … 640 640 (push name *toplevel-functions*) 641 641 (when (and (consp name) 642 642 (or 643 643 (eq 'setf (first name)) 644 644 (eq 'cl:setf (first name)))) 645 645 (push (second name) *toplevel-setf-functions*)) 646 646 ;; If NAME is not fbound, provide a dummy definition so that … … 685 685 (%SET-FDEFINITION precompile-toplevel-form) 686 686 (MOP::ENSURE-METHOD process-toplevel-mop.ensure-method) 687 687 (record-source-information-for-type process-record-source-information))) 688 688 (install-toplevel-handler (car pair) (cadr pair))) 689 689 … … 815 815 816 816 (write `(in-package ,(package-name in-package)) 817 817 :stream out) 818 818 (%stream-terpri out))) 819 819 … … 990 990 (loop for line = (read-line in nil :eof) 991 991 while (not (eq line :eof)) 992 992 do (write-line line out))))) 993 993 (delete-file temp-file) 994 994 (when (subtypep (type-of output-file) 'jar-pathname) -
trunk/abcl/src/org/armedbear/lisp/compile-system.lisp
r14931 r15569 488 488 (defun compile-system (&key quit (zip t) (cls-ext *compile-file-class-extension*) (abcl-ext *compile-file-type*) output-path) 489 489 (let ((status -1) 490 491 490 (*compile-file-class-extension* cls-ext) 491 (*compile-file-type* abcl-ext)) 492 492 (check-lisp-home) 493 493 (time -
trunk/abcl/src/org/armedbear/lisp/compiler-macro.lisp
r14914 r15569 62 62 (block ,block-name ,body)))) 63 63 `(progn 64 64 (record-source-information-for-type ',name :compiler-macro) 65 65 (setf (compiler-macro-function ',name) (function ,expander)) 66 66 ',name))))) -
trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r15223 r15569 951 951 (let* ((*compiler-debug* nil) 952 952 (method (make-jvm-method :constructor :void nil 953 953 :flags '(:public))) 954 954 ;; We don't normally need to see debugging output for constructors. 955 955 (super (class-file-superclass class)) … … 3924 3924 (with-operand-accumulation 3925 3925 ((emit-variable-operand (block-id-variable block)) 3926 3927 3926 (emit-load-externalized-object-operand (block-name block)) 3927 (compile-operand result-form nil)) 3928 3928 (emit-invokestatic +lisp+ "nonLocalReturn" (lisp-object-arg-types 3) 3929 3929 +lisp-object+)) 3930 3930 ;; Following code will not be reached, but is needed for JVM stack 3931 3931 ;; consistency. … … 3942 3942 (compile-form arg target nil)) 3943 3943 ((and (consp arg) (eq (%car arg) 'cdr) (= (length arg) 2)) 3944 3944 (compile-forms-and-maybe-emit-clear-values (second arg) 'stack nil) 3945 3945 (emit-invoke-method "cadr" target representation)) 3946 3946 (t … … 4006 4006 (with-operand-accumulation 4007 4007 ((compile-operand symbols-form nil) 4008 4008 (compile-operand values-form nil)) 4009 4009 (unless (and (single-valued-p symbols-form) 4010 4011 4010 (single-valued-p values-form)) 4011 (emit-clear-values)) 4012 4012 (save-dynamic-environment environment-register) 4013 4013 ;; Compile call to Lisp.progvBindVars(). 4014 4014 (emit-push-current-thread) 4015 4015 (emit-invokestatic +lisp+ "progvBindVars" 4016 4016 (list +lisp-object+ +lisp-object+ +lisp-thread+) nil)) 4017 4017 ;; Implicit PROGN. 4018 4018 (let ((*blocks* (cons block *blocks*))) … … 6902 6902 (compile-operand (third form) nil)) ; Result. 6903 6903 (emit-invokevirtual +lisp-thread+ "throwToTag" 6904 6904 (lisp-object-arg-types 2) nil)) 6905 6905 ;; Following code will not be reached. 6906 6906 (when target … … 7431 7431 `(lambda ,(cadr form) 7432 7432 (error 'program-error :format-control "Program error while compiling ~a" :format-arguments 7433 7434 7435 7433 (if ,condition 7434 (list (apply 'format nil ,(slot-value condition 'sys::format-control) ',(slot-value condition 'sys::format-arguments))) 7435 (list "a form"))))) 7436 7436 7437 7437 (defun compile-defun (name form environment filespec stream *declare-inline*) -
trunk/abcl/src/org/armedbear/lisp/cond.lisp
r11391 r15569 36 36 nil 37 37 (let ((clause (first clauses))) 38 39 40 41 42 43 44 45 46 47 48 49 50 38 (when (atom clause) 39 (error "COND clause is not a list: ~S" clause)) 40 (let ((test (first clause)) 41 (forms (rest clause))) 42 (if (endp forms) 43 (let ((n-result (gensym))) 44 `(let ((,n-result ,test)) 45 (if ,n-result 46 ,n-result 47 (cond ,@(rest clauses))))) 48 `(if ,test 49 (progn ,@forms) 50 (cond ,@(rest clauses)))))))) -
trunk/abcl/src/org/armedbear/lisp/copy-seq.lisp
r12516 r15569 39 39 `(let ((length (length ,sequence))) 40 40 (do ((index 0 (1+ index)) 41 41 (copy (make-sequence-of-type ,type length))) 42 42 ((= index length) copy) 43 43 (aset copy index (aref ,sequence index))))) … … 46 46 `(if (atom ,list) '() 47 47 (let ((result (cons (car ,list) '()) )) 48 49 50 48 (do ((x (cdr ,list) (cdr x)) 49 (splice result 50 (cdr (rplacd splice (cons (car x) '() ))) )) 51 51 ((atom x) (unless (null x) 52 52 (rplacd splice x)) -
trunk/abcl/src/org/armedbear/lisp/count.lisp
r12516 r15569 60 60 61 61 (defun count (item sequence &rest args &key from-end (test #'eql test-p) (test-not nil test-not-p) 62 62 (start 0) end key) 63 63 (when (and test-p test-not-p) 64 64 (error "test and test-not both supplied")) 65 65 (let* ((length (length sequence)) 66 66 (end (or end length))) 67 67 (let ((%test (if test-not-p 68 69 70 71 68 (lambda (x) 69 (not (funcall test-not item x))) 70 (lambda (x) 71 (funcall test item x))))) 72 72 (sequence::seq-dispatch sequence 73 74 75 76 77 78 79 73 (if from-end 74 (list-count-if nil t %test sequence) 75 (list-count-if nil nil %test sequence)) 76 (if from-end 77 (vector-count-if nil t %test sequence) 78 (vector-count-if nil nil %test sequence)) 79 (apply #'sequence:count item sequence args))))) 80 80 81 81 (defun count-if (test sequence &rest args &key from-end (start 0) end key) 82 82 (let* ((length (length sequence)) 83 83 (end (or end length))) 84 84 (sequence::seq-dispatch sequence 85 85 (if from-end … … 89 89 (vector-count-if nil t test sequence) 90 90 (vector-count-if nil nil test sequence)) 91 91 (apply #'sequence:count-if test sequence args)))) 92 92 93 93 (defun count-if-not (test sequence &rest args &key from-end (start 0) end key) 94 94 (let* ((length (length sequence)) 95 95 (end (or end length))) 96 96 (sequence::seq-dispatch sequence 97 97 (if from-end … … 101 101 (vector-count-if t t test sequence) 102 102 (vector-count-if t nil test sequence)) 103 103 (apply #'sequence:count-if-not test sequence args)))) -
trunk/abcl/src/org/armedbear/lisp/debug.lisp
r13434 r15569 87 87 (with-standard-io-syntax 88 88 (let ((*print-structure* nil) 89 89 (*print-readably* nil)) 90 90 (when (and *load-truename* (streamp *load-stream*)) 91 91 (simple-format *debug-io* -
trunk/abcl/src/org/armedbear/lisp/define-modify-macro.lisp
r14727 r15569 38 38 "Creates a new read-modify-write macro like PUSH or INCF." 39 39 (let ((other-args nil) 40 41 42 40 (rest-arg nil) 41 (env (gensym)) 42 (reference (gensym))) 43 43 ;; Parse out the variable names and &REST arg from the lambda list. 44 44 (do ((ll lambda-list (cdr ll)) 45 46 45 (arg nil)) 46 ((null ll)) 47 47 (setq arg (car ll)) 48 48 (cond ((eq arg '&optional)) 49 50 51 52 53 54 55 56 57 58 59 60 61 62 49 ((eq arg '&rest) 50 (if (symbolp (cadr ll)) 51 (setq rest-arg (cadr ll)) 52 (error "Non-symbol &REST arg in definition of ~S." name)) 53 (if (null (cddr ll)) 54 (return nil) 55 (error "Illegal stuff after &REST argument in DEFINE-MODIFY-MACRO."))) 56 ((memq arg '(&key &allow-other-keys &aux)) 57 (error "~S not allowed in DEFINE-MODIFY-MACRO lambda list." arg)) 58 ((symbolp arg) 59 (push arg other-args)) 60 ((and (listp arg) (symbolp (car arg))) 61 (push (car arg) other-args)) 62 (t (error "Illegal stuff in DEFINE-MODIFY-MACRO lambda list.")))) 63 63 (setq other-args (nreverse other-args)) 64 64 `(eval-when (:compile-toplevel :load-toplevel :execute) -
trunk/abcl/src/org/armedbear/lisp/defmacro.lisp
r14914 r15569 42 42 (let ((expander `(lambda (,whole ,env) ,@decls ,body))) 43 43 `(progn 44 44 (sys::record-source-information-for-type ',name :macro) 45 45 (let ((macro (make-macro ',name 46 46 (or (precompile nil ,expander) ,expander)))) -
trunk/abcl/src/org/armedbear/lisp/defpackage.lisp
r14914 r15569 155 155 `(prog1 156 156 (%defpackage ,(string package) ',nicknames ',size 157 158 159 160 157 ',shadows (ensure-available-symbols ',shadowing-imports) 158 ',(if use-p use nil) 159 (ensure-available-symbols ',imports) ',interns ',exports 160 ',local-nicknames ',doc) 161 161 ,(when (and (symbolp package) (not (keywordp package))) 162 162 `(record-source-information-for-type ',package :package)) 163 163 (record-source-information-for-type ,(intern (string package) :keyword) :package) 164 164 ))) -
trunk/abcl/src/org/armedbear/lisp/defsetf.lisp
r11391 r15569 55 55 (defmacro defsetf (access-fn &rest rest) 56 56 (cond ((not (listp (car rest))) 57 58 57 `(eval-when (:load-toplevel :compile-toplevel :execute) 58 (%define-setf-macro ',access-fn 59 59 nil 60 60 ',(car rest) 61 62 63 64 61 ,(when (and (car rest) (stringp (cadr rest))) 62 `',(cadr rest))))) 63 ((and (cdr rest) (listp (cadr rest))) 64 (destructuring-bind 65 65 (lambda-list (&rest store-variables) &body body) 66 66 rest … … 84 84 nil 85 85 ',doc)))))) 86 87 86 (t 87 (error "Ill-formed DEFSETF for ~S" access-fn)))) -
trunk/abcl/src/org/armedbear/lisp/defstruct.lisp
r15030 r15569 354 354 (cond ((eq *dd-type* 'list) 355 355 `((declaim (ftype (function * ,type) ,accessor-name)) 356 356 (record-source-information-for-type ',accessor-name '(:structure-reader ,*dd-name*)) 357 357 (setf (symbol-function ',accessor-name) 358 358 (make-list-reader ,index)))) … … 360 360 (and (consp *dd-type*) (eq (car *dd-type*) 'vector))) 361 361 `((declaim (ftype (function * ,type) ,accessor-name)) 362 362 (record-source-information-for-type ',accessor-name '(:structure-reader ,*dd-name*)) 363 363 (setf (symbol-function ',accessor-name) 364 364 (make-vector-reader ,index)) 365 365 (record-source-information-for-type ',accessor-name '(:structure-reader ,*dd-name*)) 366 366 (define-source-transform ,accessor-name (instance) 367 367 `(aref (truly-the ,',*dd-type* ,instance) ,,index)))) … … 370 370 (setf (symbol-function ',accessor-name) 371 371 (make-structure-reader ,index ',*dd-name*)) 372 372 (record-source-information-for-type ',accessor-name '(:structure-reader ,*dd-name*)) 373 373 (define-source-transform ,accessor-name (instance) 374 374 ,(if (eq type 't) … … 401 401 (cond ((eq *dd-type* 'list) 402 402 `((record-source-information-for-type '(setf ,accessor-name) '(:structure-writer ,*dd-name*)) 403 403 (setf (get ',accessor-name 'setf-function) 404 404 (make-list-writer ,index)))) 405 405 ((or (eq *dd-type* 'vector) … … 407 407 `((setf (get ',accessor-name 'setf-function) 408 408 (make-vector-writer ,index)) 409 409 (record-source-information-for-type '(setf ,accessor-name) '(:structure-writer ,*dd-name*)) 410 410 (define-source-transform (setf ,accessor-name) (value instance) 411 411 `(aset (truly-the ,',*dd-type* ,instance) ,,index ,value)))) … … 413 413 `((setf (get ',accessor-name 'setf-function) 414 414 (make-structure-writer ,index ',*dd-name*)) 415 415 (record-source-information-for-type '(setf ,accessor-name) '(:structure-writer ,*dd-name*)) 416 416 (define-source-transform (setf ,accessor-name) (value instance) 417 417 `(structure-set (the ,',*dd-name* ,instance) -
trunk/abcl/src/org/armedbear/lisp/delete-duplicates.lisp
r12516 r15569 39 39 (let ((handle (cons nil list))) 40 40 (do ((current (nthcdr start list) (cdr current)) 41 42 41 (previous (nthcdr start handle)) 42 (index start (1+ index))) 43 43 ((or (and end (= index end)) (null current)) 44 44 (cdr handle)) 45 45 (if (do ((x (if from-end 46 47 48 49 46 (nthcdr (1+ start) handle) 47 (cdr current)) 48 (cdr x)) 49 (i (1+ index) (1+ i))) 50 50 ((or (null x) 51 51 (and (not from-end) end (= i end)) 52 52 (eq x current)) 53 53 nil) 54 55 56 57 58 59 60 61 62 63 54 (if (if test-not 55 (not (funcall test-not 56 (sys::apply-key key (car current)) 57 (sys::apply-key key (car x)))) 58 (funcall test 59 (sys::apply-key key (car current)) 60 (sys::apply-key key (car x)))) 61 (return t))) 62 (rplacd previous (cdr current)) 63 (setq previous (cdr previous)))))) 64 64 65 65 66 66 (defun vector-delete-duplicates* (vector test test-not key from-end start end 67 67 &optional (length (length vector))) 68 68 (when (null end) (setf end (length vector))) 69 69 (do ((index start (1+ index)) 70 70 (jndex start)) 71 71 ((= index end) 72 (do ((index index (1+ index)) 72 (do ((index index (1+ index)) ; copy the rest of the vector 73 73 (jndex jndex (1+ jndex))) 74 74 ((= index length) … … 78 78 (setf (aref vector jndex) (aref vector index)) 79 79 (unless (position (sys::apply-key key (aref vector index)) vector :key key 80 81 80 :start (if from-end start (1+ index)) :test test 81 :end (if from-end jndex end) :test-not test-not) 82 82 (setq jndex (1+ jndex))))) 83 83 84 84 (defun delete-duplicates (sequence &rest args &key (test #'eql) test-not 85 85 (start 0) from-end end key) 86 86 (sequence::seq-dispatch sequence 87 87 (if sequence 88 88 (list-delete-duplicates* sequence test test-not key from-end start end)) 89 89 (vector-delete-duplicates* sequence test test-not key from-end start end) 90 90 (apply #'sequence:delete-duplicates sequence args))) -
trunk/abcl/src/org/armedbear/lisp/delete.lisp
r12516 r15569 47 47 (number-zapped 0)) 48 48 ((or (= index end) (= number-zapped count)) 49 (do ((index index (1+ index)) 49 (do ((index index (1+ index)) ; copy the rest of the vector 50 50 (jndex jndex (1+ jndex))) 51 51 ((= index length) … … 64 64 (terminus (1- start))) 65 65 ((or (= index terminus) (= number-zapped count)) 66 (do ((losers losers) 66 (do ((losers losers) ; delete the losers 67 67 (index start (1+ index)) 68 68 (jndex start)) 69 69 ((or (null losers) (= index end)) 70 (do ((index index (1+ index)) 70 (do ((index index (1+ index)) ; copy the rest of the vector 71 71 (jndex jndex (1+ jndex))) 72 72 ((= index length) … … 137 137 138 138 (defun delete (item sequence &rest args &key from-end (test #'eql) test-not 139 139 (start 0) end count key) 140 140 (when key 141 141 (setq key (coerce-to-function key))) 142 142 (let* ((length (length sequence)) 143 144 143 (end (or end length)) 144 (count (real-count count))) 145 145 (sequence::seq-dispatch sequence 146 146 (if from-end 147 148 149 (if from-end 150 151 147 (normal-list-delete-from-end) 148 (normal-list-delete)) 149 (if from-end 150 (normal-mumble-delete-from-end) 151 (normal-mumble-delete)) 152 152 (apply #'sequence:delete item sequence args)))) 153 153 … … 169 169 170 170 (defun delete-if (predicate sequence &rest args &key from-end (start 0) 171 171 key end count) 172 172 (when key 173 173 (setq key (coerce-to-function key))) 174 174 (let* ((length (length sequence)) 175 176 175 (end (or end length)) 176 (count (real-count count))) 177 177 (sequence::seq-dispatch sequence 178 178 (if from-end 179 180 181 (if from-end 182 183 179 (if-list-delete-from-end) 180 (if-list-delete)) 181 (if from-end 182 (if-mumble-delete-from-end) 183 (if-mumble-delete)) 184 184 (apply #'sequence:delete-if predicate sequence args)))) 185 185 … … 201 201 202 202 (defun delete-if-not (predicate sequence &rest args &key from-end (start 0) 203 203 end key count) 204 204 (when key 205 205 (setq key (coerce-to-function key))) 206 206 (let* ((length (length sequence)) 207 208 207 (end (or end length)) 208 (count (real-count count))) 209 209 (sequence::seq-dispatch sequence 210 210 (if from-end 211 212 213 (if from-end 214 215 211 (if-not-list-delete-from-end) 212 (if-not-list-delete)) 213 (if from-end 214 (if-not-mumble-delete-from-end) 215 (if-not-mumble-delete)) 216 216 (apply #'sequence:delete-if-not predicate sequence args)))) -
trunk/abcl/src/org/armedbear/lisp/delete_file.java
r15411 r15569 88 88 if (file.delete()) { 89 89 return T; 90 91 92 90 } 91 // Under Windows our fasls get placed in the ZipCache when compiled 92 ZipCache.remove(defaultedPathname); 93 93 System.gc(); 94 94 Thread.yield(); -
trunk/abcl/src/org/armedbear/lisp/describe.lisp
r14956 r15569 95 95 (describe-arglist object stream) 96 96 (let ((function-symbol (nth-value 2 (function-lambda-expression object)))) 97 98 99 100 101 102 103 97 (if (and (consp function-symbol) (eq (car function-symbol) 'macro-function)) 98 (setq function-symbol (second function-symbol))) 99 (when function-symbol 100 (let ((doc (documentation function-symbol 'function))) 101 (when doc 102 (format stream "Function documentation:~% ~A~%" doc))) 103 ))) 104 104 (INTEGER 105 105 (%describe-object object stream) -
trunk/abcl/src/org/armedbear/lisp/destructuring-bind.lisp
r15095 r15569 38 38 (defun parse-body (body &optional (doc-string-allowed t)) 39 39 (let ((decls ()) 40 40 (doc nil)) 41 41 (do ((tail body (cdr tail))) 42 43 42 ((endp tail) 43 (values tail (nreverse decls) doc)) 44 44 (let ((form (car tail))) 45 46 47 48 49 50 51 52 53 54 55 56 45 (cond ((and (stringp form) (cdr tail)) 46 (if doc-string-allowed 47 (setq doc form 48 ;; Only one doc string is allowed. 49 doc-string-allowed nil) 50 (return (values tail (nreverse decls) doc)))) 51 ((not (and (consp form) (symbolp (car form)))) 52 (return (values tail (nreverse decls) doc))) 53 ((eq (car form) 'declare) 54 (push form decls)) 55 (t 56 (return (values tail (nreverse decls) doc)))))))) 57 57 58 58 ;; We don't have DEFVAR yet... … … 77 77 (defun lambda-list-broken-key-list-error (&key kind name problem info) 78 78 (error 'program-error 79 80 81 82 83 84 85 86 87 88 89 79 :format-control (concatenate 'string "Error while parsing arguments to ~A ~S:~%" 80 (ecase problem 81 (:dotted-list 82 "Keyword/value list is dotted: ~S") 83 (:odd-length 84 "Odd number of elements in keyword/value list: ~S") 85 (:duplicate 86 "Duplicate keyword: ~S") 87 (:unknown-keyword 88 "~{Unknown keyword: ~S ; expected one of ~{~S~^, ~}~}"))) 89 :format-arguments (list kind name info))) 90 90 91 91 ;;; Return, as multiple values, a body, possibly a DECLARE form to put … … 93 93 ;;; body, and bounds on the number of arguments. 94 94 (defun parse-defmacro (lambda-list arg-list-name body name context 95 96 97 98 99 95 &key 96 (anonymousp nil) 97 (doc-string-allowed t) 98 ((:environment env-arg-name)) 99 (error-fun 'error) 100 100 (wrap-block t)) 101 101 (multiple-value-bind (forms declarations documentation) 102 102 (parse-body body doc-string-allowed) 103 103 (let ((*arg-tests* ()) 104 105 106 104 (*user-lets* ()) 105 (*system-lets* ()) 106 (*ignorable-vars* ()) 107 107 (*env-var* nil)) 108 108 (multiple-value-bind (env-arg-used minimum maximum) 109 110 111 112 109 (parse-defmacro-lambda-list lambda-list arg-list-name name 110 context error-fun (not anonymousp) 111 nil) 112 (values `(let* (,@(when env-arg-used 113 113 `((,*env-var* ,env-arg-name))) 114 114 ,@(nreverse *system-lets*)) 115 116 117 118 119 115 ,@(when *ignorable-vars* 116 `((declare (ignorable ,@*ignorable-vars*)))) 117 ,@*arg-tests* 118 (let* ,(nreverse *user-lets*) 119 ,@declarations 120 120 ,@(if wrap-block 121 121 `((block ,(fdefinition-block-name name) ,@forms)) 122 122 forms))) 123 123 `(,@(when (and env-arg-name (not env-arg-used)) 124 124 `((declare (ignore ,env-arg-name))))) 125 126 127 125 documentation 126 minimum 127 maximum))))) 128 128 129 129 (defun defmacro-error (problem name) … … 136 136 ((null remaining) 137 137 (if (and unknown-keyword 138 139 140 141 138 (not allow-other-keys) 139 (not (lookup-keyword :allow-other-keys key-list))) 140 (values :unknown-keyword (list unknown-keyword valid-keys)) 141 (values nil nil))) 142 142 (cond ((not (and (consp remaining) (listp (cdr remaining)))) 143 144 145 146 147 148 149 150 143 (return (values :dotted-list key-list))) 144 ((null (cdr remaining)) 145 (return (values :odd-length key-list))) 146 ((or (eq (car remaining) :allow-other-keys) 147 (memql (car remaining) valid-keys)) 148 (push (car remaining) already-processed)) 149 (t 150 (setq unknown-keyword (car remaining)))))) 151 151 152 152 (defun lookup-keyword (keyword key-list) … … 169 169 (defun parse-defmacro-lambda-list 170 170 (lambda-list arg-list-name name error-kind error-fun 171 171 &optional top-level env-illegal ;;env-arg-name 172 172 ) 173 173 (let* ((path-0 (if top-level `(cdr ,arg-list-name) arg-list-name)) … … 182 182 ;; in lambda lists. 183 183 (when (and (do ((list lambda-list (cdr list))) 184 185 186 184 ((atom list) nil) 185 (when (eq (car list) '&WHOLE) (return t))) 186 (not (eq (car lambda-list) '&WHOLE))) 187 187 (error "&Whole must appear first in ~S lambda-list." error-kind)) 188 188 (do ((rest-of-args lambda-list (cdr rest-of-args))) 189 190 191 192 193 189 ((atom rest-of-args) 190 (cond ((null rest-of-args) nil) 191 ;; Varlist is dotted, treat as &rest arg and exit. 192 (t (push-let-binding rest-of-args path nil) 193 (setq restp t)))) 194 194 (let ((var (car rest-of-args))) 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 195 (cond ((eq var '&whole) 196 (cond ((and (cdr rest-of-args) (symbolp (cadr rest-of-args))) 197 (setq rest-of-args (cdr rest-of-args)) 198 (push-let-binding (car rest-of-args) arg-list-name nil)) 199 ((and (cdr rest-of-args) (consp (cadr rest-of-args))) 200 (pop rest-of-args) 201 (let* ((destructuring-lambda-list (car rest-of-args)) 202 (sub (gensym "WHOLE-SUBLIST"))) 203 (push-sub-list-binding 204 sub arg-list-name destructuring-lambda-list 205 name error-kind error-fun) 206 (parse-defmacro-lambda-list 207 destructuring-lambda-list sub name error-kind error-fun))) 208 (t 209 (defmacro-error "&WHOLE" name)))) 210 ((eq var '&environment) 211 (cond (env-illegal 212 (error "&ENVIRONMENT is not valid with ~S." error-kind)) 213 ((not top-level) 214 (error "&ENVIRONMENT is only valid at top level of lambda list."))) 215 (cond ((and (cdr rest-of-args) (symbolp (cadr rest-of-args))) 216 (setq rest-of-args (cdr rest-of-args)) 217 217 (setq *env-var* (car rest-of-args) 218 218 env-arg-used t)) 219 220 221 222 223 224 225 226 227 228 229 230 231 219 (t 220 (defmacro-error "&ENVIRONMENT" name)))) 221 ((or (eq var '&rest) (eq var '&body)) 222 (cond ((and (cdr rest-of-args) (symbolp (cadr rest-of-args))) 223 (setq rest-of-args (cdr rest-of-args)) 224 (setq restp t) 225 (push-let-binding (car rest-of-args) path nil)) 226 ((and (cdr rest-of-args) (consp (cadr rest-of-args))) 227 (pop rest-of-args) 228 (setq restp t) 229 (let* ((destructuring-lambda-list (car rest-of-args)) 230 (sub (gensym "REST-SUBLIST"))) 231 (push-sub-list-binding sub path destructuring-lambda-list 232 232 name error-kind error-fun) 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 233 (parse-defmacro-lambda-list 234 destructuring-lambda-list sub name error-kind error-fun))) 235 (t 236 (defmacro-error (symbol-name var) name)))) 237 ((eq var '&optional) 238 (setq now-processing :optionals)) 239 ((eq var '&key) 240 (setq now-processing :keywords) 241 (setq rest-name (gensym "KEYWORDS-")) 242 (push rest-name *ignorable-vars*) 243 (setq restp t) 244 (push-let-binding rest-name path t)) 245 ((eq var '&allow-other-keys) 246 (setq allow-other-keys-p t)) 247 ((eq var '&aux) 248 (setq now-processing :auxs)) 249 ((listp var) 250 (case now-processing 251 (:required 252 (let ((sub-list-name (gensym "SUBLIST-"))) 253 (push-sub-list-binding sub-list-name `(car ,path) var 254 name error-kind error-fun) 255 (parse-defmacro-lambda-list var sub-list-name name 256 error-kind error-fun)) 257 (setq path `(cdr ,path)) 258 (incf minimum) 259 (incf maximum)) 260 (:optionals 261 (when (> (length var) 3) 262 (error "more than variable, initform, and suppliedp in &optional binding ~S" 263 263 var)) 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 264 (push-optional-binding (car var) (cadr var) (caddr var) 265 `(not (null ,path)) `(car ,path) 266 name error-kind error-fun) 267 (setq path `(cdr ,path)) 268 (incf maximum)) 269 (:keywords 270 (let* ((keyword-given (consp (car var))) 271 (variable (if keyword-given 272 (cadar var) 273 (car var))) 274 (keyword (if keyword-given 275 (caar var) 276 (make-keyword variable))) 277 (supplied-p (caddr var))) 278 (push-optional-binding variable (cadr var) supplied-p 279 `(keyword-supplied-p ',keyword 280 ,rest-name) 281 `(lookup-keyword ',keyword 282 ,rest-name) 283 name error-kind error-fun) 284 (push keyword keys))) 285 (:auxs (push-let-binding (car var) (cadr var) nil)))) 286 ((symbolp var) 287 (case now-processing 288 (:required 289 (incf minimum) 290 (incf maximum) 291 (push-let-binding var `(car ,path) nil) 292 (setq path `(cdr ,path))) 293 (:optionals 294 (incf maximum) 295 (push-let-binding var `(car ,path) nil `(not (null ,path))) 296 (setq path `(cdr ,path))) 297 (:keywords 298 (let ((key (make-keyword var))) 299 (push-let-binding var `(lookup-keyword ,key ,rest-name) 300 nil) 301 (push key keys))) 302 (:auxs 303 (push-let-binding var nil nil)))) 304 (t 305 (error "non-symbol in lambda-list: ~S" var))))) 306 306 ;; Generate code to check the number of arguments. 307 307 (push `(unless (<= ,minimum … … 328 328 (when ,problem 329 329 ,(if (eq error-fun 'error) 330 330 `(lambda-list-broken-key-list-error 331 331 :kind ',error-kind 332 332 ,@(when name `(:name ',name)) … … 346 346 (let ((var (gensym "TEMP-"))) 347 347 (push `(,variable 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 348 (let ((,var ,path)) 349 (if (listp ,var) 350 ,var 351 ,(if (eq error-fun 'error) 352 `(bogus-sublist-error 353 :kind ',error-kind 354 ,@(when name `(:name ',name)) 355 :object ,var 356 :lambda-list ',object) 357 `(,error-fun 'defmacro-bogus-sublist-error 358 :kind ',error-kind 359 ,@(when name `(:name ',name)) 360 :object ,var 361 :lambda-list ',object))))) 362 *system-lets*))) 363 363 364 364 (defun push-let-binding (variable path systemp &optional condition 365 365 (init-form nil)) 366 366 (let ((let-form (if condition 367 368 367 `(,variable (if ,condition ,path ,init-form)) 368 `(,variable ,path)))) 369 369 (if systemp 370 371 370 (push let-form *system-lets*) 371 (push let-form *user-lets*)))) 372 372 373 373 (defun push-optional-binding (value-var init-form supplied-var condition path 374 374 name error-kind error-fun) 375 375 (unless supplied-var 376 376 (setq supplied-var (gensym "SUPPLIEDP-"))) 377 377 (push-let-binding supplied-var condition t) 378 378 (cond ((consp value-var) 379 380 381 382 383 384 385 386 387 388 379 (let ((whole-thing (gensym "OPTIONAL-SUBLIST-"))) 380 (push-sub-list-binding whole-thing 381 `(if ,supplied-var ,path ,init-form) 382 value-var name error-kind error-fun) 383 (parse-defmacro-lambda-list value-var whole-thing name 384 error-kind error-fun))) 385 ((symbolp value-var) 386 (push-let-binding value-var path nil supplied-var init-form)) 387 (t 388 (error "Illegal optional variable name: ~S" value-var)))) 389 389 390 390 (defmacro destructuring-bind (lambda-list arg-list &rest body) 391 391 (let* ((arg-list-name (gensym "ARG-LIST-"))) 392 392 (multiple-value-bind (body local-decls) 393 394 393 (parse-defmacro lambda-list arg-list-name body nil 'destructuring-bind 394 :anonymousp t 395 395 :doc-string-allowed nil 396 396 :wrap-block nil) 397 397 `(let ((,arg-list-name ,arg-list)) 398 399 398 ,@local-decls 399 ,body)))) 400 400 401 401 ;; Redefine SYS:MAKE-MACRO-EXPANDER to use PARSE-DEFMACRO. … … 415 415 (define-condition defmacro-lambda-list-bind-error (program-error) 416 416 ((kind :reader defmacro-lambda-list-bind-error-kind 417 417 :initarg :kind) 418 418 (name :reader defmacro-lambda-list-bind-error-name 419 420 419 :initarg :name 420 :initform nil))) 421 421 422 422 (defun print-defmacro-ll-bind-error-intro (condition stream) 423 423 (if (null (defmacro-lambda-list-bind-error-name condition)) 424 424 (format stream 425 426 427 425 "Error while parsing arguments to ~A in ~S:~%" 426 (defmacro-lambda-list-bind-error-kind condition) 427 (condition-function-name condition)) 428 428 (format stream 429 430 431 429 "Error while parsing arguments to ~A ~S:~%" 430 (defmacro-lambda-list-bind-error-kind condition) 431 (defmacro-lambda-list-bind-error-name condition)))) 432 432 433 433 (define-condition defmacro-bogus-sublist-error 434 434 (defmacro-lambda-list-bind-error) 435 435 ((object :reader defmacro-bogus-sublist-error-object :initarg :object) 436 436 (lambda-list :reader defmacro-bogus-sublist-error-lambda-list 437 437 :initarg :lambda-list)) 438 438 (:report 439 439 (lambda (condition stream) 440 440 (print-defmacro-ll-bind-error-intro condition stream) 441 441 (format stream 442 443 444 442 "Bogus sublist:~% ~S~%to satisfy lambda-list:~% ~:S~%" 443 (defmacro-bogus-sublist-error-object condition) 444 (defmacro-bogus-sublist-error-lambda-list condition))))) 445 445 446 446 … … 449 449 ((argument :reader defmacro-ll-arg-count-error-argument :initarg :argument) 450 450 (lambda-list :reader defmacro-ll-arg-count-error-lambda-list 451 451 :initarg :lambda-list) 452 452 (minimum :reader defmacro-ll-arg-count-error-minimum :initarg :minimum) 453 453 (maximum :reader defmacro-ll-arg-count-error-maximum :initarg :maximum)) … … 456 456 (print-defmacro-ll-bind-error-intro condition stream) 457 457 (format stream 458 459 460 461 458 "Invalid number of elements in:~% ~:S~%~ 459 to satisfy lambda-list:~% ~:S~%" 460 (defmacro-ll-arg-count-error-argument condition) 461 (defmacro-ll-arg-count-error-lambda-list condition)) 462 462 (cond ((null (defmacro-ll-arg-count-error-maximum condition)) 463 464 465 466 467 468 469 470 471 472 463 (format stream "Expected at least ~D" 464 (defmacro-ll-arg-count-error-minimum condition))) 465 ((= (defmacro-ll-arg-count-error-minimum condition) 466 (defmacro-ll-arg-count-error-maximum condition)) 467 (format stream "Expected exactly ~D" 468 (defmacro-ll-arg-count-error-minimum condition))) 469 (t 470 (format stream "Expected between ~D and ~D" 471 (defmacro-ll-arg-count-error-minimum condition) 472 (defmacro-ll-arg-count-error-maximum condition)))) 473 473 (format stream ", but got ~D." 474 474 (length (defmacro-ll-arg-count-error-argument condition)))))) 475 475 476 476 (define-condition defmacro-lambda-list-broken-key-list-error 477 477 (defmacro-lambda-list-bind-error) 478 478 ((problem :reader defmacro-ll-broken-key-list-error-problem 479 479 :initarg :problem) 480 480 (info :reader defmacro-ll-broken-key-list-error-info :initarg :info)) 481 481 (:report (lambda (condition stream) 482 483 484 485 486 487 488 489 490 491 492 493 494 482 (print-defmacro-ll-bind-error-intro condition stream) 483 (format stream 484 (ecase 485 (defmacro-ll-broken-key-list-error-problem condition) 486 (:dotted-list 487 "Keyword/value list is dotted: ~S") 488 (:odd-length 489 "Odd number of elements in keyword/value list: ~S") 490 (:duplicate 491 "Duplicate keyword: ~S") 492 (:unknown-keyword 493 "~{Unknown keyword: ~S; expected one of ~{~S~^, ~}~}")) 494 (defmacro-ll-broken-key-list-error-info condition))))) 495 495 |# -
trunk/abcl/src/org/armedbear/lisp/digest.lisp
r14582 r15569 43 43 "Returned ASCIIfied representation of SHA256 digest of byte-based resource at PATHS-OR-STRINGs." 44 44 (unless (and (null (rest paths-or-strings)) 45 45 (pathnamep (first paths-or-strings))) 46 46 (warn "Unaudited computation of cryptographic digest initiated.")) ;; TODO Need tests with some tool for verification 47 47 (let ((first (first paths-or-strings)) -
trunk/abcl/src/org/armedbear/lisp/disassemble.lisp
r15280 r15569 174 174 (defun get-loaded-from (function) 175 175 (let* ((jfield (find "loadedFrom" (java:jcall "getDeclaredFields" (java:jclass "org.armedbear.lisp.Function")) 176 176 :key 'java:jfield-name :test 'equal))) 177 177 (java:jcall "setAccessible" jfield java:+true+) 178 178 (java:jcall "get" jfield function))) … … 180 180 (defun set-loaded-from (function value) 181 181 (let* ((jfield (find "loadedFrom" (java:jcall "getDeclaredFields" (java:jclass "org.armedbear.lisp.Function")) 182 182 :key 'java:jfield-name :test 'equal))) 183 183 (java:jcall "setAccessible" jfield java:+true+) 184 184 (java:jcall "set" jfield function value))) … … 187 187 (defun fasl-compiled-closure-class-bytes (function) 188 188 (let* ((loaded-from (get-loaded-from function)) 189 190 191 192 193 194 195 196 197 198 189 (class-name (subseq (java:jcall "getName" (java:jcall "getClass" function)) (length "org.armedbear.lisp."))) 190 (url (if (not (eq (pathname-device loaded-from) :unspecific)) 191 ;; we're loading from a jar 192 (java:jnew "java.net.URL" 193 (namestring (make-pathname :directory (pathname-directory loaded-from) 194 :device (pathname-device loaded-from) 195 :name class-name :type "cls"))) 196 ;; we're loading from a fasl file 197 (java:jnew "java.net.URL" (namestring (make-pathname :device (list loaded-from) 198 :name class-name :type "cls")))))) 199 199 (read-byte-array-from-stream (java:jcall "openStream" url)))) 200 200 -
trunk/abcl/src/org/armedbear/lisp/do.lisp
r11391 r15569 35 35 (defun do-do-body (varlist endlist decls-and-code bind step name block) 36 36 (let* ((inits ()) 37 38 39 37 (steps ()) 38 (L1 (gensym)) 39 (L2 (gensym))) 40 40 ;; Check for illegal old-style do. 41 41 (when (or (not (listp varlist)) (atom endlist)) … … 44 44 (dolist (v varlist) 45 45 (cond ((symbolp v) (push v inits)) 46 47 48 49 50 51 52 53 54 55 46 ((listp v) 47 (unless (symbolp (first v)) 48 (error "~S step variable is not a symbol: ~S" name (first v))) 49 (case (length v) 50 (1 (push (first v) inits)) 51 (2 (push v inits)) 52 (3 (push (list (first v) (second v)) inits) 53 (setq steps (list* (third v) (first v) steps))) 54 (t (error "~S is an illegal form for a ~S varlist." v name)))) 55 (t (error "~S is an illegal form for a ~S varlist." v name)))) 56 56 ;; Construct the new form. 57 57 (multiple-value-bind (code decls) (parse-body decls-and-code nil) -
trunk/abcl/src/org/armedbear/lisp/dotimes.java
r15552 r15569 153 153 thread.resetSpecialBindings(mark); 154 154 ext.inactive = true; 155 155 while (thread.envStack.pop() != ext) {}; 156 156 } 157 157 } -
trunk/abcl/src/org/armedbear/lisp/dribble.lisp
r15541 r15569 55 55 the dribble file, and quits logging." 56 56 (cond (pathname 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 57 (let* ((new-dribble-stream 58 (open pathname 59 :direction :output 60 :if-exists if-exists 61 :if-does-not-exist :create)) 62 (new-standard-output 63 (make-broadcast-stream *standard-output* new-dribble-stream)) 64 (new-error-output 65 (make-broadcast-stream *error-output* new-dribble-stream)) 66 (new-standard-input 67 (make-echo-stream *standard-input* new-dribble-stream))) 68 (push (list *dribble-stream* *standard-input* *standard-output* 69 *error-output*) 70 *previous-dribble-streams*) 71 (setf *dribble-stream* new-dribble-stream) 72 (setf *standard-input* new-standard-input) 73 (setf *standard-output* new-standard-output) 74 (setf *error-output* new-error-output) 75 75 ;; Starting a new internal REPL for dribbling 76 76 (loop do … … 86 86 (format *error-output* "~a~%" c) 87 87 (error c))))))) 88 89 90 91 92 93 94 95 96 88 ((null *dribble-stream*) 89 (error "Not currently dribbling.")) 90 (t 91 (let ((old-streams (pop *previous-dribble-streams*))) 92 (close *dribble-stream*) 93 (setf *dribble-stream* (first old-streams)) 94 (setf *standard-input* (second old-streams)) 95 (setf *standard-output* (third old-streams)) 96 (setf *error-output* (fourth old-streams))))) 97 97 (values)) -
trunk/abcl/src/org/armedbear/lisp/ed.lisp
r14106 r15569 41 41 the file system." 42 42 (dolist (fun *ed-functions* 43 44 45 43 (error 'simple-error 44 :format-control "Don't know how to ~S ~A" 45 :format-arguments (list 'ed x))) 46 46 (when (funcall fun x) 47 47 (return))) -
trunk/abcl/src/org/armedbear/lisp/ensure-directories-exist.lisp
r14173 r15569 36 36 (defun ensure-directories-exist (pathspec &key (verbose nil)) 37 37 (let ((pathname (pathname pathspec)) 38 38 (created-p nil)) 39 39 ;;; CLHS: Function ENSURE-DIRECTORIES-EXIST "An error of type 40 40 ;;; file-error is signaled if the host, device, or directory part of … … 44 44 (wild-pathname-p pathname :directory)) 45 45 (error 'file-error 46 47 46 :format-control "Bad place for a wild HOST, DEVICE, or DIRECTORY component." 47 :pathname pathname)) 48 48 (let ((dir (pathname-directory pathname))) 49 49 (loop :for i :from 1 :upto (length dir) -
trunk/abcl/src/org/armedbear/lisp/extensible-sequences-base.lisp
r12516 r15569 11 11 12 12 (shadow '(ELT LENGTH COUNT "COUNT-IF" "COUNT-IF-NOT" 13 14 15 16 17 18 19 20 21 22 13 "FIND" "FIND-IF" "FIND-IF-NOT" 14 "POSITION" "POSITION-IF" "POSITION-IF-NOT" 15 "SUBSEQ" "COPY-SEQ" "FILL" 16 "NSUBSTITUTE" "NSUBSTITUTE-IF" "NSUBSTITUTE-IF-NOT" 17 "SUBSTITUTE" "SUBSTITUTE-IF" "SUBSTITUTE-IF-NOT" 18 "REPLACE" "REVERSE" "NREVERSE" "REDUCE" 19 "MISMATCH" "SEARCH" 20 "DELETE" "DELETE-IF" "DELETE-IF-NOT" 21 "REMOVE" "REMOVE-IF" "REMOVE-IF-NOT" 22 "DELETE-DUPLICATES" "REMOVE-DUPLICATES" "SORT" "STABLE-SORT")) 23 23 24 24 (export '(DOSEQUENCE 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 25 26 MAKE-SEQUENCE-ITERATOR MAKE-SIMPLE-SEQUENCE-ITERATOR 27 28 ITERATOR-STEP ITERATOR-ENDP ITERATOR-ELEMENT 29 ITERATOR-INDEX ITERATOR-COPY 30 31 WITH-SEQUENCE-ITERATOR WITH-SEQUENCE-ITERATOR-FUNCTIONS 32 33 CANONIZE-TEST CANONIZE-KEY 34 35 LENGTH ELT 36 MAKE-SEQUENCE-LIKE ADJUST-SEQUENCE 37 38 COUNT COUNT-IF COUNT-IF-NOT 39 FIND FIND-IF FIND-IF-NOT 40 POSITION POSITION-IF POSITION-IF-NOT 41 SUBSEQ COPY-SEQ FILL 42 NSUBSTITUTE NSUBSTITUTE-IF NSUBSTITUTE-IF-NOT 43 SUBSTITUTE SUBSTITUTE-IF SUBSTITUTE-IF-NOT 44 REPLACE REVERSE NREVERSE REDUCE 45 MISMATCH SEARCH 46 DELETE DELETE-IF DELETE-IF-NOT 47 REMOVE REMOVE-IF REMOVE-IF-NOT 48 DELETE-DUPLICATES REMOVE-DUPLICATES SORT STABLE-SORT)) 49 49 50 50 ;;; Adapted from SBCL … … 67 67 ,array-form) 68 68 (if (typep ,sequence 'sequence) 69 70 71 69 ,other-form 70 (error 'type-error 71 :datum ,sequence :expected-type 'sequence)))) 72 72 `((let ((,sequence (ext:truly-the vector ,sequence))) 73 73 (declare (ignorable ,sequence)) … … 83 83 (let ((size (length sequence))) 84 84 (error "The bounding indices ~S and ~S are bad for a sequence of length ~S" 85 85 start end size))) 86 86 87 87 (defun %set-elt (sequence index value) -
trunk/abcl/src/org/armedbear/lisp/extensible-sequences.lisp
r15544 r15569 986 986 (defun filter-dolist-declarations (decls) 987 987 (mapcar (lambda (decl) 988 989 990 991 992 993 994 988 `(declare ,@(remove-if 989 (lambda (clause) 990 (and (consp clause) 991 (or (eq (car clause) 'type) 992 (eq (car clause) 'ignore)))) 993 (cdr decl)))) 994 decls))) 995 995 996 996 ;; just like DOLIST, but with one-dimensional arrays … … 1013 1013 1014 1014 (defmacro sequence:dosequence ((e sequence &optional return &rest args &key 1015 1015 from-end start end) &body body) 1016 1016 (declare (ignore from-end start end)) 1017 1017 (multiple-value-bind (forms decls) -
trunk/abcl/src/org/armedbear/lisp/fdefinition.lisp
r15388 r15569 48 48 (flet ((truename-no-error (p) 49 49 (if (and (pathnamep p) 50 51 52 53 50 (not (and 51 (stringp (pathname-device p)) 52 (string= (pathname-device p) 53 "emacs-buffer"))) 54 54 (not (wild-pathname-p p))) 55 55 (probe-file p) … … 131 131 (setf source-position *source-position*)) 132 132 (let ((source (if source-position 133 134 133 (list source-pathname source-position) 134 (list source-pathname)))) 135 135 (let ((sym (if (consp name) (second name) name)) 136 136 (new `(,type ,(if (symbolp (car source)) (car source) (namestring (car source))) ,(second source)))) 137 137 (if (autoloadp 'delete) 138 138 (put sym 'sys::source (cons new (get sym 'sys::source nil))) 139 139 (put sym 'sys::source (cons new (delete new (get sym 'sys::source nil) 140 140 :test (lambda(a b) (and (equalp (car a) (car b)) (equalp (second a) (second b) )))))))))) -
trunk/abcl/src/org/armedbear/lisp/fill.lisp
r12516 r15569 55 55 (list-fill sequence item start end) 56 56 (cond ((and (stringp sequence) 57 58 59 60 61 57 (zerop start) 58 (null end)) 59 (simple-string-fill sequence item)) 60 (t 61 (vector-fill sequence item start end))) 62 62 (sequence:fill sequence item 63 64 65 63 :start start 64 :end (sequence::%check-generic-sequence-bounds 65 sequence start end)))) -
trunk/abcl/src/org/armedbear/lisp/find-all-symbols.lisp
r11391 r15569 34 34 (defun find-all-symbols (string) 35 35 (let ((string (string string)) 36 36 (res ())) 37 37 (dolist (package (list-all-packages)) 38 38 (multiple-value-bind (symbol status) (find-symbol string package) -
trunk/abcl/src/org/armedbear/lisp/find.lisp
r12516 r15569 38 38 (defmacro vector-locater-macro (sequence body-form return-type) 39 39 `(let ((incrementer (if from-end -1 1)) 40 41 40 (start (if from-end (1- (the fixnum end)) start)) 41 (end (if from-end (1- (the fixnum start)) end))) 42 42 (declare (fixnum start end incrementer)) 43 43 (do ((index start (+ index incrementer)) 44 45 44 ,@(case return-type (:position nil) (:element '(current)))) 45 ((= index end) ()) 46 46 (declare (fixnum index)) 47 47 ,@(case return-type 48 49 48 (:position nil) 49 (:element `((setf current (aref ,sequence index))))) 50 50 ,body-form))) 51 51 52 52 (defmacro locater-test-not (item sequence seq-type return-type) 53 53 (let ((seq-ref (case return-type 54 55 56 57 58 59 60 61 54 (:position 55 (case seq-type 56 (:vector `(aref ,sequence index)) 57 (:list `(pop ,sequence)))) 58 (:element 'current))) 59 (return (case return-type 60 (:position 'index) 61 (:element 'current)))) 62 62 `(if test-not 63 64 65 66 63 (if (not (funcall test-not ,item (sys::apply-key key ,seq-ref))) 64 (return ,return)) 65 (if (funcall test ,item (sys::apply-key key ,seq-ref)) 66 (return ,return))))) 67 67 68 68 (defmacro vector-locater (item sequence return-type) 69 69 `(vector-locater-macro ,sequence 70 71 70 (locater-test-not ,item ,sequence :vector ,return-type) 71 ,return-type)) 72 72 73 73 (defmacro locater-if-test (test sequence seq-type return-type sense) 74 74 (let ((seq-ref (case return-type 75 76 77 78 79 80 81 82 75 (:position 76 (case seq-type 77 (:vector `(aref ,sequence index)) 78 (:list `(pop ,sequence)))) 79 (:element 'current))) 80 (return (case return-type 81 (:position 'index) 82 (:element 'current)))) 83 83 (if sense 84 85 86 87 84 `(if (funcall ,test (sys::apply-key key ,seq-ref)) 85 (return ,return)) 86 `(if (not (funcall ,test (sys::apply-key key ,seq-ref))) 87 (return ,return))))) 88 88 89 89 (defmacro vector-locater-if-macro (test sequence return-type sense) 90 90 `(vector-locater-macro ,sequence 91 92 91 (locater-if-test ,test ,sequence :vector ,return-type ,sense) 92 ,return-type)) 93 93 94 94 (defmacro vector-locater-if (test sequence return-type) … … 101 101 `(if from-end 102 102 (do ((sequence (nthcdr (- (the fixnum (length sequence)) 103 104 105 106 107 108 109 110 111 112 113 103 (the fixnum end)) 104 (reverse (the list ,sequence)))) 105 (index (1- (the fixnum end)) (1- index)) 106 (terminus (1- (the fixnum start))) 107 ,@(case return-type (:position nil) (:element '(current)))) 108 ((or (= index terminus) (null sequence)) ()) 109 (declare (fixnum index terminus)) 110 ,@(case return-type 111 (:position nil) 112 (:element `((setf current (pop ,sequence))))) 113 ,body-form) 114 114 (do ((sequence (nthcdr start ,sequence)) 115 116 117 118 119 120 121 122 115 (index start (1+ index)) 116 ,@(case return-type (:position nil) (:element '(current)))) 117 ((or (= index (the fixnum end)) (null sequence)) ()) 118 (declare (fixnum index)) 119 ,@(case return-type 120 (:position nil) 121 (:element `((setf current (pop ,sequence))))) 122 ,body-form))) 123 123 124 124 (defmacro list-locater (item sequence return-type) 125 125 `(list-locater-macro ,sequence 126 127 126 (locater-test-not ,item ,sequence :list ,return-type) 127 ,return-type)) 128 128 129 129 (defmacro list-locater-if-macro (test sequence return-type sense) 130 130 `(list-locater-macro ,sequence 131 132 131 (locater-if-test ,test ,sequence :list ,return-type ,sense) 132 ,return-type)) 133 133 134 134 (defmacro list-locater-if (test sequence return-type) … … 146 146 147 147 (defun position (item sequence &rest args &key from-end (test #'eql) test-not 148 148 (start 0) end key) 149 149 (sequence::seq-dispatch sequence 150 150 (list-position* item sequence from-end test test-not start end key) … … 213 213 214 214 (defun find (item sequence &rest args &key from-end (test #'eql) test-not 215 215 (start 0) end key) 216 216 (let ((end (check-sequence-bounds sequence start end))) 217 217 (sequence::seq-dispatch sequence -
trunk/abcl/src/org/armedbear/lisp/format.lisp
r15124 r15569 106 106 (defmacro once-only (specs &body body) 107 107 (named-let frob ((specs specs) 108 108 (body body)) 109 109 (if (null specs) 110 110 `(progn ,@body) … … 128 128 ;;; interpretation of the arguments is as follows: 129 129 ;;; 130 ;;; X 131 ;;; 130 ;;; X - The floating point number to convert, which must not be 131 ;;; negative. 132 132 ;;; WIDTH - The preferred field width, used to determine the number 133 ;;; 134 ;;; 135 ;;; 136 ;;; 137 ;;; 138 ;;; 133 ;;; of fraction digits to produce if the FDIGITS parameter 134 ;;; is unspecified or NIL. If the non-fraction digits and the 135 ;;; decimal point alone exceed this width, no fraction digits 136 ;;; will be produced unless a non-NIL value of FDIGITS has been 137 ;;; specified. Field overflow is not considerd an error at this 138 ;;; level. 139 139 ;;; FDIGITS - The number of fractional digits to produce. Insignificant 140 ;;; 141 ;;; 142 ;;; 143 ;;; 140 ;;; trailing zeroes may be introduced as needed. May be 141 ;;; unspecified or NIL, in which case as many digits as possible 142 ;;; are generated, subject to the constraint that there are no 143 ;;; trailing zeroes. 144 144 ;;; SCALE - If this parameter is specified or non-NIL, then the number 145 ;;; 146 ;;; 145 ;;; printed is (* x (expt 10 scale)). This scaling is exact, 146 ;;; and cannot lose precision. 147 147 ;;; FMIN - This parameter, if specified or non-NIL, is the minimum 148 ;;; 149 ;;; 150 ;;; 151 ;;; 152 ;;; 148 ;;; number of fraction digits which will be produced, regardless 149 ;;; of the value of WIDTH or FDIGITS. This feature is used by 150 ;;; the ~E format directive to prevent complete loss of 151 ;;; significance in the printed value due to a bogus choice of 152 ;;; scale factor. 153 153 ;;; 154 154 ;;; Most of the optional arguments are for the benefit for FORMAT and are not … … 162 162 ;;; DIGIT-LENGTH - The length of the string DIGIT-STRING. 163 163 ;;; LEADING-POINT - True if the first character of DIGIT-STRING is the 164 ;;; 164 ;;; decimal point. 165 165 ;;; TRAILING-POINT - True if the last character of DIGIT-STRING is the 166 ;;; 166 ;;; decimal point. 167 167 ;;; POINT-POS - The position of the digit preceding the decimal 168 ;;; 168 ;;; point. Zero indicates point before first digit. 169 169 ;;; 170 170 ;;; NOTE: FLONUM-TO-STRING goes to a lot of trouble to guarantee … … 189 189 (declare (ignore fmin)) ; FIXME 190 190 (cond ((zerop x) 191 192