[armedbear-cvs] r13461 - trunk/abcl/src/org/armedbear/lisp
ehuelsmann at common-lisp.net
ehuelsmann at common-lisp.net
Thu Aug 11 17:01:42 UTC 2011
Author: ehuelsmann
Date: Thu Aug 11 10:01:41 2011
New Revision: 13461
Log:
Print expected minimum and maximum argument list lengths in
WrongNumberOfArguments program errors.
Modified:
trunk/abcl/src/org/armedbear/lisp/CharacterFunctions.java
trunk/abcl/src/org/armedbear/lisp/Closure.java
trunk/abcl/src/org/armedbear/lisp/Extensions.java
trunk/abcl/src/org/armedbear/lisp/JHandler.java
trunk/abcl/src/org/armedbear/lisp/JProxy.java
trunk/abcl/src/org/armedbear/lisp/Java.java
trunk/abcl/src/org/armedbear/lisp/LispThread.java
trunk/abcl/src/org/armedbear/lisp/PackageFunctions.java
trunk/abcl/src/org/armedbear/lisp/Pathname.java
trunk/abcl/src/org/armedbear/lisp/Primitives.java
trunk/abcl/src/org/armedbear/lisp/Readtable.java
trunk/abcl/src/org/armedbear/lisp/SpecialOperators.java
trunk/abcl/src/org/armedbear/lisp/Stream.java
trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java
trunk/abcl/src/org/armedbear/lisp/adjust_array.java
trunk/abcl/src/org/armedbear/lisp/make_array.java
trunk/abcl/src/org/armedbear/lisp/peek_char.java
trunk/abcl/src/org/armedbear/lisp/room.java
Modified: trunk/abcl/src/org/armedbear/lisp/CharacterFunctions.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/CharacterFunctions.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/CharacterFunctions.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -44,7 +44,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
@@ -79,7 +79,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
@@ -129,7 +129,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
@@ -168,7 +168,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
@@ -207,7 +207,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
@@ -245,7 +245,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
@@ -294,7 +294,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
@@ -333,7 +333,7 @@
@Override
public LispObject execute()
{
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg)
Modified: trunk/abcl/src/org/armedbear/lisp/Closure.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Closure.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/Closure.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -666,12 +666,12 @@
{
// Fixed arity.
if (argsLength != arity)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, arity));
return args;
}
// Not fixed arity.
if (argsLength < minArgs)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, minArgs, -1));
final LispObject[] array = new LispObject[variables.length];
int index = 0;
// The bindings established here (if any) are lost when this function
@@ -925,12 +925,12 @@
{
// Fixed arity.
if (argsLength != arity)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, arity));
return args;
}
// Not fixed arity.
if (argsLength < minArgs)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, minArgs, -1));
final LispObject[] array = new LispObject[variables.length];
int index = 0;
// Required parameters.
Modified: trunk/abcl/src/org/armedbear/lisp/Extensions.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Extensions.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/Extensions.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -55,7 +55,7 @@
public LispObject execute(LispObject args, Environment env)
{
if (args.length() != 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2));
return eval(args.cadr(), env, LispThread.currentThread());
}
}
Modified: trunk/abcl/src/org/armedbear/lisp/JHandler.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/JHandler.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/JHandler.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -103,7 +103,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length != 5)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 5));
Map<String,Entry> entryTable = null;
Object object = args[0].javaInstance();
String event = ((Symbol)args[1]).getName();
Modified: trunk/abcl/src/org/armedbear/lisp/JProxy.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/JProxy.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/JProxy.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -199,7 +199,7 @@
public LispObject execute(LispObject[] args) {
int length = args.length;
if (length != 1) {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1));
}
if(!(args[0] instanceof Function)) {
return error(new TypeError(args[0], Symbol.FUNCTION));
@@ -215,7 +215,7 @@
public LispObject execute(final LispObject[] args) {
int length = args.length;
if (length != 3) {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 3));
}
if(!(args[0] instanceof Cons)) {
return error(new TypeError(args[0], new SimpleString("CONS")));
Modified: trunk/abcl/src/org/armedbear/lisp/Java.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Java.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/Java.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -168,7 +168,7 @@
{
if (args.length < 2 || args.length > 4)
- error(new WrongNumberOfArgumentsException(fun));
+ error(new WrongNumberOfArgumentsException(fun, 2, 4));
String fieldName = null;
Class c;
Field f;
@@ -330,7 +330,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 1)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 1, -1));
try {
final Class<?> c = javaClass(args[0]);
int argCount = 0;
@@ -382,7 +382,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 2)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 2, -1));
final Class<?> c = javaClass(args[0]);
String methodName = args[1].getStringValue();
try {
@@ -435,7 +435,7 @@
{
if (args.length < 2)
- error(new WrongNumberOfArgumentsException(fun));
+ error(new WrongNumberOfArgumentsException(fun, 2, -1));
try {
Method m = null;
LispObject methodRef = args[0];
@@ -545,7 +545,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 1)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 1, -1));
LispObject classRef = args[0];
try {
Constructor constructor;
@@ -610,7 +610,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 2)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 2, -1));
try {
Class c = javaClass(args[0]);
int[] dimensions = new int[args.length - 1];
@@ -630,7 +630,7 @@
{
if (args.length < 2)
- error(new WrongNumberOfArgumentsException(fun));
+ error(new WrongNumberOfArgumentsException(fun, 2, -1));
try {
Object a = args[0].javaInstance();
for (int i = 1; i<args.length - 1; i++)
@@ -704,7 +704,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 3)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 3, -1));
try {
Object a = args[0].javaInstance();
LispObject v = args[1];
@@ -792,7 +792,7 @@
@Override
public LispObject execute(LispObject[] args) {
if (args.length < 2) {
- error(new WrongNumberOfArgumentsException(this, 2));
+ error(new WrongNumberOfArgumentsException(this, 2, -1));
}
final LispObject methodArg = args[0];
final LispObject instanceArg = args[1];
@@ -837,7 +837,7 @@
{
if (args.length < 2)
- error(new WrongNumberOfArgumentsException(fun, 2));
+ error(new WrongNumberOfArgumentsException(fun, 2, -1));
try {
final LispObject methodArg = args[0];
final LispObject instanceArg = args[1];
@@ -1115,7 +1115,7 @@
Symbol.WARN.getSymbolFunction()
.execute(new SimpleString("JAVA:MAKE-IMMEDIATE-OBJECT is deprecated."));
if (args.length < 1)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 1, -1));
LispObject object = args[0];
if (args.length > 1) {
LispObject type = args[1];
Modified: trunk/abcl/src/org/armedbear/lisp/LispThread.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispThread.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/LispThread.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -604,6 +604,10 @@
stack = stack.getNext();
}
+ public final Environment setEnv(Environment env) {
+ return (stack != null) ? stack.setEnv(env) : null;
+ }
+
public void resetStack()
{
stack = null;
@@ -928,22 +932,22 @@
return unreadableString(sb.toString());
}
- @DocString(name="make-thread", args="function &optional &key name")
+ @DocString(name="make-thread", args="function &key name")
private static final Primitive MAKE_THREAD =
- new Primitive("make-thread", PACKAGE_THREADS, true, "function &optional &key name")
+ new Primitive("make-thread", PACKAGE_THREADS, true, "function &key name")
{
@Override
public LispObject execute(LispObject[] args)
{
final int length = args.length;
if (length == 0)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 1, -1));
LispObject name = NIL;
if (length > 1) {
if ((length - 1) % 2 != 0)
error(new ProgramError("Odd number of keyword arguments."));
if (length > 3)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, -1, 2)); // don't count the keyword itself as an argument
if (args[1] == Keyword.NAME)
name = args[2].STRING();
else
@@ -1115,7 +1119,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, -1));
final LispThread thread;
if (args[0] instanceof LispThread) {
thread = (LispThread) args[0];
@@ -1154,7 +1158,7 @@
{
if (args.length > 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, -1, 1));
int limit = args.length > 0 ? Fixnum.getValue(args[0]) : 0;
return currentThread().backtrace(limit);
}
@@ -1168,7 +1172,7 @@
{
if (args.length != 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1));
return checkStackFrame(args[0]).toLispString();
}
@@ -1183,7 +1187,7 @@
{
if (args.length != 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1));
return checkStackFrame(args[0]).toLispList();
}
@@ -1212,7 +1216,7 @@
{
if (args == NIL)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1));
LispThread thread = LispThread.currentThread();
synchronized (eval(args.car(), env, thread).lockableInstance()) {
Modified: trunk/abcl/src/org/armedbear/lisp/PackageFunctions.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/PackageFunctions.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/PackageFunctions.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -105,7 +105,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length == 0 || args.length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
LispObject symbols = args[0];
Package pkg =
args.length == 2 ? coerceToPackage(args[1]) : getCurrentPackage();
@@ -129,7 +129,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length == 0 || args.length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
LispObject symbols = args[0];
Package pkg =
args.length == 2 ? coerceToPackage(args[1]) : getCurrentPackage();
@@ -153,7 +153,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length == 0 || args.length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
LispObject symbols = args[0];
Package pkg =
args.length == 2 ? coerceToPackage(args[1]) : getCurrentPackage();
@@ -177,7 +177,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length == 0 || args.length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
LispObject symbols = args[0];
Package pkg =
args.length == 2 ? coerceToPackage(args[1]) : getCurrentPackage();
@@ -224,7 +224,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 1 || args.length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
Package pkg;
if (args.length == 2)
pkg = coerceToPackage(args[1]);
@@ -251,7 +251,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 2 || args.length > 3)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, 3));
Package pkg = coerceToPackage(args[0]);
String newName = javaString(args[1]);
LispObject nicknames = args.length == 3 ? checkList(args[2]) : NIL;
@@ -279,7 +279,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length != 10)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 10));
final String packageName = args[0].getStringValue();
LispObject nicknames = checkList(args[1]);
// FIXME size is ignored
Modified: trunk/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Pathname.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/Pathname.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -1538,7 +1538,7 @@
case 1:
return NIL;
default:
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 0, 1));
}
}
}
Modified: trunk/abcl/src/org/armedbear/lisp/Primitives.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Primitives.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/Primitives.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -82,7 +82,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -112,7 +112,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -148,7 +148,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -793,7 +793,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -839,7 +839,7 @@
{
if (args == NIL)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
final LispThread thread = LispThread.currentThread();
if (eval(args.car(), env, thread) != NIL) {
args = args.cdr();
@@ -862,7 +862,7 @@
{
if (args == NIL)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
final LispThread thread = LispThread.currentThread();
if (eval(args.car(), env, thread) == NIL) {
args = args.cdr();
@@ -1244,7 +1244,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -1288,7 +1288,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -1337,7 +1337,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -1379,7 +1379,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -1421,7 +1421,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -1463,7 +1463,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -1624,7 +1624,7 @@
@Override
public LispObject execute(LispObject[] args) {
if (args.length < 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
if (args[0] instanceof Condition)
return error((Condition)args[0]);
return error(new SimpleCondition());
@@ -1685,7 +1685,7 @@
@Override
public LispObject execute(LispObject[] args) {
if (args.length < 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, -1));
LispObject destination = args[0];
// Copy remaining arguments.
LispObject[] _args = new LispObject[args.length - 1];
@@ -2299,7 +2299,7 @@
@Override
public LispObject execute(LispObject[] args) {
if (args.length < 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
final AbstractArray array;
LispObject r = args[0];
array = checkArray(r);
@@ -2355,7 +2355,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -2679,7 +2679,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
@@ -2772,11 +2772,11 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, -1));
}
@Override
public LispObject execute(LispObject arg) {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, -1));
}
@Override
public LispObject execute(LispObject fun, LispObject args)
@@ -2910,7 +2910,7 @@
{
final int numArgs = args.length;
if (numArgs < 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, -1));
int commonLength = -1;
for (int i = 1; i < numArgs; i++) {
if (!args[i].listp())
@@ -2986,7 +2986,7 @@
{
final int numArgs = args.length;
if (numArgs < 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, -1));
int commonLength = -1;
for (int i = 1; i < numArgs; i++) {
if (!args[i].listp())
@@ -3154,7 +3154,7 @@
@Override
public LispObject execute(LispObject[] args) {
if (args.length == 0 || args.length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
Symbol symbol = checkSymbol(args[0]);
Package pkg;
if (args.length == 2)
@@ -3322,7 +3322,7 @@
@Override
public LispObject execute(LispObject[] args) {
if (args.length < 1 || args.length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
Package pkg;
if (args.length == 2)
pkg = coerceToPackage(args[1]);
@@ -3697,7 +3697,7 @@
{
if (args.length() != 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1));
Binding binding = env.getTagBinding(args.car());
if (binding == null)
return error(new ControlError("No tag named " +
@@ -3720,7 +3720,7 @@
{
if (args == NIL)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
LispObject tag;
tag = checkSymbol(args.car());
LispObject body = ((Cons)args).cdr();
@@ -3756,7 +3756,7 @@
{
final int length = args.length();
if (length < 1 || length > 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
Symbol symbol;
symbol = checkSymbol(args.car());
@@ -3779,7 +3779,7 @@
{
if (args.length() < 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
final LispThread thread = LispThread.currentThread();
LispObject tag = eval(args.car(), env, thread);
thread.pushCatchTag(tag);
@@ -3813,7 +3813,7 @@
{
if (args.length() != 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2));
final LispThread thread = LispThread.currentThread();
thread.throwToTag(eval(args.car(), env, thread),
eval(args.cadr(), env, thread));
@@ -3964,7 +3964,7 @@
{
if (args.length() == 0)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
final LispThread thread = LispThread.currentThread();
LispObject result = eval(args.car(), env, thread);
LispObject[] values = thread._values;
@@ -3990,7 +3990,7 @@
{
if (args.length() == 0)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
final LispThread thread = LispThread.currentThread();
LispObject function;
LispObject obj = eval(args.car(), env, thread);
@@ -4096,7 +4096,7 @@
{
if (args.length() != 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1));
final LispThread thread = LispThread.currentThread();
LispObject result = eval(((Cons)args).car, env, thread);
LispObject[] values = thread._values;
@@ -4125,7 +4125,7 @@
{
if (args.length() != 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2));
final LispThread thread = LispThread.currentThread();
int n = Fixnum.getValue(eval(args.car(), env, thread));
if (n < 0)
@@ -4391,7 +4391,7 @@
@Override
public LispObject execute() {
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
}
@Override
public LispObject execute(LispObject arg) {
Modified: trunk/abcl/src/org/armedbear/lisp/Readtable.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Readtable.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/Readtable.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -445,7 +445,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 1 || args.length > 3)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 3));
char dispChar = LispCharacter.getValue(args[0]);
LispObject non_terminating_p;
if (args.length > 1)
@@ -472,7 +472,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 2 || args.length > 3)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 3));
char dispChar = LispCharacter.getValue(args[0]);
char subChar = LispCharacter.getValue(args[1]);
Readtable readtable;
@@ -494,7 +494,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 3 || args.length > 4)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 3, 4));
char dispChar = LispCharacter.getValue(args[0]);
char subChar = LispCharacter.getValue(args[1]);
LispObject function = coerceToFunction(args[2]);
@@ -518,7 +518,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length < 2 || args.length > 4)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, 4));
char toChar = LispCharacter.getValue(args[0]);
char fromChar = LispCharacter.getValue(args[1]);
Readtable toReadtable;
Modified: trunk/abcl/src/org/armedbear/lisp/SpecialOperators.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SpecialOperators.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/SpecialOperators.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -50,7 +50,7 @@
{
if (args.cdr() != NIL)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1));
return args.car();
}
};
@@ -80,7 +80,7 @@
return eval((((Cons)args).cdr).cadr(), env, thread);
}
default:
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, 3));
}
}
};
@@ -97,7 +97,7 @@
{
if (args == NIL)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
return _let(args, env, false);
}
};
@@ -114,7 +114,7 @@
{
if (args == NIL)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, -1));
return _let(args, env, true);
}
};
@@ -237,7 +237,7 @@
return eval(args.car(), new Environment(),
LispThread.currentThread());
default:
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 2));
}
}
};
@@ -378,7 +378,7 @@
{
if (args.length() != 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2));
LispObject rv = eval(args.cadr(), env, LispThread.currentThread());
// check only the most simple types: single symbols
@@ -416,7 +416,7 @@
{
if (args.length() < 2)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 2, -1));
final LispThread thread = LispThread.currentThread();
final LispObject symbols = checkList(eval(args.car(), env, thread));
LispObject values = checkList(eval(args.cadr(), env, thread));
Modified: trunk/abcl/src/org/armedbear/lisp/Stream.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Stream.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/Stream.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -2080,7 +2080,7 @@
@Override
public LispObject execute(LispObject[] args) {
if (args.length > 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, -1, 1));
final Stream in;
if (args.length == 0)
in = checkCharacterInputStream(Symbol.STANDARD_INPUT.symbolValue());
@@ -2178,7 +2178,7 @@
public LispObject execute (LispObject[] args) {
int length = args.length;
if (length < 1 || length > 3)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 1, 3));
final Stream in = checkBinaryInputStream(args[0]);
boolean eofError = length > 1 ? (args[1] != NIL) : true;
LispObject eofValue = length > 2 ? args[2] : NIL;
@@ -2351,7 +2351,7 @@
public LispObject execute(LispObject[] args) {
int length = args.length;
if (length > 4)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, -1, 4));
Stream stream =
length > 0 ? inSynonymOf(args[0]) : getStandardInput();
boolean eofError = length > 1 ? (args[1] != NIL) : true;
@@ -2408,7 +2408,7 @@
public LispObject execute(LispObject[] args) {
int length = args.length;
if (length > 4)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, -1, 4));
Stream stream =
length > 0 ? inSynonymOf(args[0]) : getStandardInput();
boolean eofError = length > 1 ? (args[1] != NIL) : true;
@@ -2427,7 +2427,7 @@
public LispObject execute(LispObject[] args) {
int length = args.length;
if (length < 1 || length > 3)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, 1, 3));
char c = LispCharacter.getValue(args[0]);
Stream stream =
length > 1 ? inSynonymOf(args[1]) : getStandardInput();
Modified: trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -38,22 +38,29 @@
public final class WrongNumberOfArgumentsException extends ProgramError
{
private Operator operator;
- private int expectedArgs;
+ private int expectedMinArgs;
+ private int expectedMaxArgs;
private String message;
public WrongNumberOfArgumentsException(Operator operator) {
this(operator, -1);
}
- public WrongNumberOfArgumentsException(Operator operator, int expectedArgs) {
+ public WrongNumberOfArgumentsException(Operator operator, int expectedMin,
+ int expectedMax) {
// This is really just an ordinary PROGRAM-ERROR, broken out into its
// own Java class as a convenience for the implementation.
super(StandardClass.PROGRAM_ERROR);
this.operator = operator;
- this.expectedArgs = expectedArgs;
+ this.expectedMinArgs = expectedMinArgs;
+ this.expectedMaxArgs = expectedMaxArgs;
setFormatControl(getMessage());
setFormatArguments(NIL);
}
+
+ public WrongNumberOfArgumentsException(Operator operator, int expectedArgs) {
+ this(operator, expectedArgs, expectedArgs);
+ }
public WrongNumberOfArgumentsException(String message) {
super(StandardClass.PROGRAM_ERROR);
@@ -74,9 +81,22 @@
StringBuilder sb =
new StringBuilder("Wrong number of arguments for "
+ operator.princToString());
- if(expectedArgs >= 0) {
+ if(expectedMinArgs >= 0 || expectedMaxArgs >= 0) {
sb.append("; ");
- sb.append(expectedArgs);
+
+ if (expectedMinArgs == expectedMaxArgs) {
+ sb.append(expectedMinArgs);
+ } else if (expectedMaxArgs < 0) {
+ sb.append("at least ");
+ sb.append(expectedMinArgs);
+ } else if (expectedMinArgs < 0) {
+ sb.append("at most ");
+ sb.append(expectedMaxArgs);
+ } else {
+ sb.append("between ").append(expectedMinArgs);
+ sb.append(" and ").append(expectedMaxArgs);
+ }
+
sb.append(" expected");
}
sb.append('.');
Modified: trunk/abcl/src/org/armedbear/lisp/adjust_array.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/adjust_array.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/adjust_array.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -49,7 +49,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length != 10)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 10));
AbstractArray array = checkArray(args[0]);
LispObject dimensions = args[1];
LispObject elementType = args[2];
Modified: trunk/abcl/src/org/armedbear/lisp/make_array.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/make_array.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/make_array.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -49,7 +49,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length != 9)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, 9));
LispObject dimensions = args[0];
LispObject elementType = args[1];
LispObject initialElement = args[2];
Modified: trunk/abcl/src/org/armedbear/lisp/peek_char.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/peek_char.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/peek_char.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -49,7 +49,7 @@
{
int length = args.length;
if (length > 5)
- error(new WrongNumberOfArgumentsException(this));
+ error(new WrongNumberOfArgumentsException(this, -1, 5));
LispObject peekType = length > 0 ? args[0] : NIL;
Stream stream = length > 1 ? inSynonymOf(args[1]) : getStandardInput();
boolean eofError = length > 2 ? (args[2] != NIL) : true;
Modified: trunk/abcl/src/org/armedbear/lisp/room.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/room.java Thu Aug 11 08:44:29 2011 (r13460)
+++ trunk/abcl/src/org/armedbear/lisp/room.java Thu Aug 11 10:01:41 2011 (r13461)
@@ -47,7 +47,7 @@
public LispObject execute(LispObject[] args)
{
if (args.length > 1)
- return error(new WrongNumberOfArgumentsException(this));
+ return error(new WrongNumberOfArgumentsException(this, -1, 1));
Runtime runtime = Runtime.getRuntime();
long total = runtime.totalMemory();
long free = runtime.freeMemory();
More information about the armedbear-cvs
mailing list