[armedbear-cvs] r13885 - trunk/abcl/src/org/armedbear/lisp
ehuelsmann at common-lisp.net
ehuelsmann at common-lisp.net
Wed Feb 29 22:35:44 UTC 2012
Author: ehuelsmann
Date: Wed Feb 29 14:35:41 2012
New Revision: 13885
Log:
Report the actual parameters passed in a function call with mismatched
parameter counts.
Modified:
trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java
trunk/abcl/src/org/armedbear/lisp/Lisp.java
trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java
Modified: trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java Wed Feb 29 01:40:48 2012 (r13884)
+++ trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java Wed Feb 29 14:35:41 2012 (r13885)
@@ -609,7 +609,7 @@
{
// Fixed arity.
if (args.length != arity)
- error(new WrongNumberOfArgumentsException(function, arity));
+ error(new WrongNumberOfArgumentsException(function, list(args), arity));
return args;
}
// Not fixed arity.
@@ -639,7 +639,7 @@
{
// Fixed arity.
if (argsLength != arity)
- error(new WrongNumberOfArgumentsException(function, arity));
+ error(new WrongNumberOfArgumentsException(function, list(args), arity));
return args;
}
// Not fixed arity.
Modified: trunk/abcl/src/org/armedbear/lisp/Lisp.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Lisp.java Wed Feb 29 01:40:48 2012 (r13884)
+++ trunk/abcl/src/org/armedbear/lisp/Lisp.java Wed Feb 29 14:35:41 2012 (r13885)
@@ -882,6 +882,13 @@
env.bind(sym, value);
}
+ public static LispObject list(LispObject[] obj) {
+ LispObject theList = NIL;
+ if (obj.length > 0)
+ for (int i = obj.length - 1; i >= 0; i--)
+ theList = new Cons(obj[i], theList);
+ return theList;
+ }
public static final Cons list(LispObject obj1, LispObject... remaining)
{
Modified: trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java Wed Feb 29 01:40:48 2012 (r13884)
+++ trunk/abcl/src/org/armedbear/lisp/WrongNumberOfArgumentsException.java Wed Feb 29 14:35:41 2012 (r13885)
@@ -40,28 +40,40 @@
private Operator operator;
private int expectedMinArgs;
private int expectedMaxArgs;
+ private LispObject actualArgs;
private String message;
public WrongNumberOfArgumentsException(Operator operator) {
this(operator, -1);
}
- public WrongNumberOfArgumentsException(Operator operator, int expectedMin,
- int expectedMax) {
+ public WrongNumberOfArgumentsException(Operator operator, LispObject args,
+ 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.expectedMinArgs = expectedMin;
this.expectedMaxArgs = expectedMax;
+ this.actualArgs = args;
setFormatControl(getMessage());
setFormatArguments(NIL);
}
-
+
+ public WrongNumberOfArgumentsException(Operator operator,
+ int expectedMin, int expectedMax) {
+ this(operator, null, expectedMin, expectedMax);
+ }
+
public WrongNumberOfArgumentsException(Operator operator, int expectedArgs) {
this(operator, expectedArgs, expectedArgs);
}
+ public WrongNumberOfArgumentsException(Operator operator, LispObject args,
+ int expectedArgs) {
+ this(operator, args, expectedArgs, expectedArgs);
+ }
+
public WrongNumberOfArgumentsException(String message) {
super(StandardClass.PROGRAM_ERROR);
if(message == null) {
@@ -99,6 +111,10 @@
sb.append(" expected");
}
+ if (actualArgs != null) {
+ sb.append(" -- provided: ");
+ sb.append(actualArgs.princToString());
+ }
sb.append('.');
return message = sb.toString();
}
More information about the armedbear-cvs
mailing list