call type_error when possible

parent 6c8b6978
......@@ -138,7 +138,7 @@ public abstract class AbstractBitVector extends AbstractVector
}
// Fall through...
}
error(new TypeError(obj, Symbol.BIT));
type_error(obj, Symbol.BIT);
}
@Override
......
......@@ -133,7 +133,7 @@ public class ArithmeticError extends LispError
return ((ArithmeticError)arg).getOperation();
}
else {
return error(new TypeError(arg, Symbol.ARITHMETIC_ERROR));
return type_error(arg, Symbol.ARITHMETIC_ERROR);
}
}
};
......@@ -148,7 +148,7 @@ public class ArithmeticError extends LispError
return ((ArithmeticError)arg).getOperands();
}
else {
return error(new TypeError(arg, Symbol.ARITHMETIC_ERROR));
return type_error(arg, Symbol.ARITHMETIC_ERROR);
}
}
};
......
......@@ -178,7 +178,7 @@ public final class BasicVector_UnsignedByte16 extends AbstractVector
}
}
else {
error(new TypeError(obj, UNSIGNED_BYTE_16));
type_error(obj, UNSIGNED_BYTE_16);
}
}
......@@ -263,7 +263,7 @@ public final class BasicVector_UnsignedByte16 extends AbstractVector
for (int i = 0; i < newCapacity; i++)
newElements[i] = initialContents.elt(i);
} else
error(new TypeError(initialContents, Symbol.SEQUENCE));
type_error(initialContents, Symbol.SEQUENCE);
return new BasicVector_UnsignedByte16(newElements);
}
if (capacity != newCapacity) {
......
......@@ -243,10 +243,10 @@ public final class BroadcastStream extends Stream
streams[i] = (Stream) args[i];
continue;
} else
return error(new TypeError(args[i], list(Symbol.SATISFIES,
Symbol.OUTPUT_STREAM_P)));
return type_error(args[i],
list(Symbol.SATISFIES, Symbol.OUTPUT_STREAM_P));
} else
return error(new TypeError(args[i], Symbol.STREAM));
return type_error(args[i], Symbol.STREAM);
}
// All is well.
return new BroadcastStream(streams);
......@@ -268,7 +268,7 @@ public final class BroadcastStream extends Stream
result = new Cons(streams[i], result);
return result;
}
return error(new TypeError(arg, Symbol.BROADCAST_STREAM));
return type_error(arg, Symbol.BROADCAST_STREAM);
}
};
}
......@@ -123,7 +123,7 @@ public final class ByteArrayOutputStream extends Stream
if (arg instanceof ByteArrayOutputStream) {
return JavaObject.getInstance(((ByteArrayOutputStream)arg).getByteArray());
}
return error(new TypeError(this, Symbol.STREAM)); //TODO
return type_error(this, Symbol.STREAM); //TODO
}
};
......@@ -137,7 +137,7 @@ public final class ByteArrayOutputStream extends Stream
if (arg instanceof ByteArrayOutputStream)
return new BasicVector_UnsignedByte8(((ByteArrayOutputStream)arg).getByteArray());
return error(new TypeError(this, Symbol.STREAM)); // TODO
return type_error(this, Symbol.STREAM); // TODO
}
};
......
......@@ -379,7 +379,7 @@ public final class ComplexVector extends AbstractVector
for (int i = 0; i < newCapacity; i++)
newElements[i] = initialContents.elt(i);
} else
error(new TypeError(initialContents, Symbol.SEQUENCE));
type_error(initialContents, Symbol.SEQUENCE);
elements = newElements;
} else {
if (elements == null) {
......
......@@ -381,7 +381,7 @@ public final class ComplexVector_UnsignedByte32 extends AbstractVector
for (int i = 0; i < newCapacity; i++)
newElements[i] = initialContents.elt(i);
} else
error(new TypeError(initialContents, Symbol.SEQUENCE));
type_error(initialContents, Symbol.SEQUENCE);
elements = newElements;
} else {
if (elements == null) {
......
......@@ -393,7 +393,7 @@ public final class ComplexVector_UnsignedByte8 extends AbstractVector
for (int i = 0; i < newCapacity; i++)
newElements[i] = coerceLispObjectToJavaByte(initialContents.elt(i));
} else
error(new TypeError(initialContents, Symbol.SEQUENCE));
type_error(initialContents, Symbol.SEQUENCE);
elements = newElements;
} else {
if (elements == null) {
......
......@@ -273,7 +273,7 @@ public final class ConcatenatedStream extends Stream
{
if (arg instanceof ConcatenatedStream)
return ((ConcatenatedStream)arg).streams;
return error(new TypeError(arg, Symbol.CONCATENATED_STREAM));
return type_error(arg, Symbol.CONCATENATED_STREAM);
}
};
}
......@@ -428,7 +428,7 @@ public final class HashTableFunctions
} else if (first instanceof WeakHashTable) {
return ((WeakHashTable)first).getWeakness();
}
return error(new TypeError(first, Symbol.HASH_TABLE));
return type_error(first, Symbol.HASH_TABLE);
}
};
......
......@@ -202,7 +202,7 @@ public final class JProxy
return error(new WrongNumberOfArgumentsException(this, 1));
}
if(!(args[0] instanceof Function)) {
return error(new TypeError(args[0], Symbol.FUNCTION));
return type_error(args[0], Symbol.FUNCTION);
}
return new JavaObject(new LispInvocationHandler((Function) args[0]));
}
......@@ -218,7 +218,7 @@ public final class JProxy
return error(new WrongNumberOfArgumentsException(this, 3));
}
if(!(args[0] instanceof Cons)) {
return error(new TypeError(args[0], new SimpleString("CONS")));
return type_error(args[0], Symbol.CONS);
}
Class[] ifaces = new Class[args[0].length()];
LispObject ifList = args[0];
......
......@@ -458,7 +458,7 @@ public final class Java
error(new LispError("no such method"));
}
} else
error(new TypeError("wrong type: " + methodRef));
type_error(methodRef, Symbol.STRING);
Object[] methodArgs = new Object[args.length-2];
Class[] argTypes = m.getParameterTypes();
for (int i = 2; i < args.length; i++) {
......@@ -1232,7 +1232,7 @@ public final class Java
try {
return JavaObject.getInstance(o, c);
} catch(ClassCastException e) {
return error(new TypeError(javaObject, new SimpleString(c.getName())));
return type_error(javaObject, new SimpleString(c.getName()));
}
}
};
......
......@@ -277,7 +277,7 @@ public class Layout extends LispObject
return arg;
oldLayout = Symbol.CLASS_LAYOUT.execute(lispClass);
} else {
return error(new TypeError(arg, Symbol.CLASS));
return type_error(arg, Symbol.CLASS);
}
Layout newLayout = new Layout((Layout)oldLayout);
......
......@@ -2639,7 +2639,7 @@ public class Pathname extends LispObject {
@Override
public LispObject execute(LispObject arg) {
if (!(arg instanceof AbstractString)) {
return error(new TypeError(arg, Symbol.STRING));
return type_error(arg, Symbol.STRING);
}
String result = uriDecode(((AbstractString)arg).toString());
return new SimpleString(result);
......@@ -2666,7 +2666,7 @@ public class Pathname extends LispObject {
@Override
public LispObject execute(LispObject arg) {
if (!(arg instanceof AbstractString)) {
return error(new TypeError(arg, Symbol.STRING));
return type_error(arg, Symbol.STRING);
}
String result = uriEncode(((AbstractString)arg).toString());
return new SimpleString(result);
......
......@@ -271,7 +271,7 @@ public final class Ratio extends LispObject
Complex c = (Complex) obj;
return Complex.getInstance(add(c.getRealPart()), c.getImaginaryPart());
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -307,7 +307,7 @@ public final class Ratio extends LispObject
return Complex.getInstance(subtract(c.getRealPart()),
Fixnum.ZERO.subtract(c.getImaginaryPart()));
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -337,7 +337,7 @@ public final class Ratio extends LispObject
return Complex.getInstance(multiplyBy(c.getRealPart()),
multiplyBy(c.getImaginaryPart()));
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -379,7 +379,7 @@ public final class Ratio extends LispObject
return Complex.getInstance(realPart.divideBy(d),
imagPart.divideBy(d));
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -394,7 +394,7 @@ public final class Ratio extends LispObject
return isEqualTo(((DoubleFloat)obj).rational());
if (obj.numberp())
return false;
error(new TypeError(obj, Symbol.NUMBER));
type_error(obj, Symbol.NUMBER);
// Not reached.
return false;
}
......@@ -425,7 +425,7 @@ public final class Ratio extends LispObject
return isLessThan(((SingleFloat)obj).rational());
if (obj instanceof DoubleFloat)
return isLessThan(((DoubleFloat)obj).rational());
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -450,7 +450,7 @@ public final class Ratio extends LispObject
return isGreaterThan(((SingleFloat)obj).rational());
if (obj instanceof DoubleFloat)
return isGreaterThan(((DoubleFloat)obj).rational());
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -475,7 +475,7 @@ public final class Ratio extends LispObject
return isLessThanOrEqualTo(((SingleFloat)obj).rational());
if (obj instanceof DoubleFloat)
return isLessThanOrEqualTo(((DoubleFloat)obj).rational());
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -500,7 +500,7 @@ public final class Ratio extends LispObject
return isGreaterThanOrEqualTo(((SingleFloat)obj).rational());
if (obj instanceof DoubleFloat)
return isGreaterThanOrEqualTo(((DoubleFloat)obj).rational());
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -527,7 +527,7 @@ public final class Ratio extends LispObject
n = ((Ratio)obj).numerator();
d = ((Ratio)obj).denominator();
} else {
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
// Invert and multiply.
BigInteger num = numerator.multiply(d);
......
......@@ -211,7 +211,7 @@ public final class SimpleBitVector extends AbstractBitVector
for (int i = 0; i < newCapacity; i++)
v.aset(i, initialContents.elt(i));
} else
error(new TypeError(initialContents, Symbol.SEQUENCE));
type_error(initialContents, Symbol.SEQUENCE);
return v;
}
if (capacity != newCapacity) {
......
......@@ -338,7 +338,7 @@ public final class SimpleVector extends AbstractVector
newData[i] = initialContents.elt(i);
}
else
error(new TypeError(initialContents, Symbol.SEQUENCE));
type_error(initialContents, Symbol.SEQUENCE);
return new SimpleVector(newData);
}
if (capacity != newCapacity)
......
......@@ -284,7 +284,7 @@ public final class SingleFloat extends LispObject
Complex c = (Complex) obj;
return Complex.getInstance(add(c.getRealPart()), c.getImaginaryPart());
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -315,7 +315,7 @@ public final class SingleFloat extends LispObject
return Complex.getInstance(subtract(c.getRealPart()),
ZERO.subtract(c.getImaginaryPart()));
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -336,7 +336,7 @@ public final class SingleFloat extends LispObject
return Complex.getInstance(multiplyBy(c.getRealPart()),
multiplyBy(c.getImaginaryPart()));
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -362,7 +362,7 @@ public final class SingleFloat extends LispObject
multiplyBy(Fixnum.MINUS_ONE).multiplyBy(im).divideBy(denom);
return Complex.getInstance(resX, resY);
}
return error(new TypeError(obj, Symbol.NUMBER));
return type_error(obj, Symbol.NUMBER);
}
@Override
......@@ -380,7 +380,7 @@ public final class SingleFloat extends LispObject
return rational().isEqualTo(obj);
if (obj instanceof Complex)
return obj.isEqualTo(this);
error(new TypeError(obj, Symbol.NUMBER));
type_error(obj, Symbol.NUMBER);
// Not reached.
return false;
}
......@@ -404,7 +404,7 @@ public final class SingleFloat extends LispObject
return rational().isLessThan(obj);
if (obj instanceof Ratio)
return rational().isLessThan(obj);
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -422,7 +422,7 @@ public final class SingleFloat extends LispObject
return rational().isGreaterThan(obj);
if (obj instanceof Ratio)
return rational().isGreaterThan(obj);
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -440,7 +440,7 @@ public final class SingleFloat extends LispObject
return rational().isLessThanOrEqualTo(obj);
if (obj instanceof Ratio)
return rational().isLessThanOrEqualTo(obj);
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -458,7 +458,7 @@ public final class SingleFloat extends LispObject
return rational().isGreaterThanOrEqualTo(obj);
if (obj instanceof Ratio)
return rational().isGreaterThanOrEqualTo(obj);
error(new TypeError(obj, Symbol.REAL));
type_error(obj, Symbol.REAL);
// Not reached.
return false;
}
......@@ -542,7 +542,7 @@ public final class SingleFloat extends LispObject
LispObject remainder = subtract(product);
return thread.setValues(result, remainder);
}
return error(new TypeError(obj, Symbol.REAL));
return type_error(obj, Symbol.REAL);
}
@Override
......
......@@ -350,7 +350,7 @@ public class Stream extends StructureObject {
if (arg instanceof Stream) {
return ((Stream)arg).getExternalFormat();
} else {
return error(new TypeError(arg, Symbol.STREAM));
return type_error(arg, Symbol.STREAM);
}
}
}
......
......@@ -162,7 +162,7 @@ public class StreamError extends LispError
{
if (arg instanceof StreamError)
return ((StreamError)arg).getStream();
return error(new TypeError(arg, Symbol.STREAM_ERROR));
return type_error(arg, Symbol.STREAM_ERROR);
}
};
}
......@@ -242,7 +242,7 @@ public final class SynonymStream extends Stream
{
if (arg instanceof SynonymStream)
return ((SynonymStream)arg).symbol;
return error(new TypeError(arg, Symbol.SYNONYM_STREAM));
return type_error(arg, Symbol.SYNONYM_STREAM);
}
};
}
......@@ -118,7 +118,7 @@ public final class ZeroRankArray extends AbstractArray
public void aset(int index, LispObject obj)
{
if (obj.typep(elementType) == NIL)
error(new TypeError(obj, elementType));
type_error(obj, elementType);
if (index == 0)
data = obj;
else
......@@ -129,7 +129,7 @@ public final class ZeroRankArray extends AbstractArray
public void fill(LispObject obj)
{
if (obj.typep(elementType) == NIL)
error(new TypeError(obj, elementType));
type_error(obj, elementType);
data = obj;
}
......
......@@ -136,7 +136,7 @@ public final class dotimes extends SpecialOperator
result = eval(resultForm, ext, thread);
}
else
return error(new TypeError(limit, Symbol.INTEGER));
return type_error(limit, Symbol.INTEGER);
return result;
}
catch (Return ret)
......
......@@ -92,7 +92,7 @@ public final class function_info
return LispThread.currentThread().setValues(cons.cdr(), T);
}
} else if (cons != NIL)
error(new TypeError(cons, Symbol.LIST));
type_error(cons, Symbol.LIST);
info = info.cdr();
}
}
......@@ -124,7 +124,7 @@ public final class function_info
return value;
}
} else if (cons != NIL)
error(new TypeError(cons, Symbol.LIST));
type_error(cons, Symbol.LIST);
alist = alist.cdr();
}
// Not found.
......
......@@ -48,7 +48,7 @@ public final class interactive_stream_p extends Primitive
{
if (arg instanceof Stream)
return ((Stream)arg).isInteractive() ? T : NIL;
return error(new TypeError(arg, Symbol.STREAM));
return type_error(arg, Symbol.STREAM);
}
private static final Primitive INTERACTIVE_STREAM_P = new interactive_stream_p();
......
......@@ -57,7 +57,7 @@ public final class logandc1 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.not().and(n2));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
if (first instanceof Bignum) {
BigInteger n1 = ((Bignum)first).value;
......@@ -69,9 +69,9 @@ public final class logandc1 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.not().and(n2));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
return error(new TypeError(first, Symbol.INTEGER));
return type_error(first, Symbol.INTEGER);
}
private static final Primitive LOGANDC1 = new logandc1();
......
......@@ -60,7 +60,7 @@ public final class logandc2 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.and(n2.not()));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
if (first instanceof Bignum) {
BigInteger n1 = ((Bignum)first).value;
......@@ -72,9 +72,9 @@ public final class logandc2 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.and(n2.not()));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
return error(new TypeError(first, Symbol.INTEGER));
return type_error(first, Symbol.INTEGER);
}
private static final Primitive LOGANDC2 = new logandc2();
......
......@@ -60,7 +60,7 @@ public final class logeqv extends Primitive
return arg;
if (arg instanceof Bignum)
return arg;
return error(new TypeError(arg, Symbol.INTEGER));
return type_error(arg, Symbol.INTEGER);
}
@Override
......@@ -75,7 +75,7 @@ public final class logeqv extends Primitive
else if (arg instanceof Bignum)
n = ((Bignum)arg).value;
else
return error(new TypeError(arg, Symbol.INTEGER));
return type_error(arg, Symbol.INTEGER);
if (result == null)
result = n;
else
......
......@@ -57,7 +57,7 @@ public final class lognand extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.and(n2).not());
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
if (first instanceof Bignum) {
BigInteger n1 = ((Bignum)first).value;
......@@ -69,9 +69,9 @@ public final class lognand extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.and(n2).not());
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
return error(new TypeError(first, Symbol.INTEGER));
return type_error(first, Symbol.INTEGER);
}
private static final Primitive LOGNAND = new lognand();
......
......@@ -60,7 +60,7 @@ public final class logorc1 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.not().or(n2));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
if (first instanceof Bignum) {
BigInteger n1 = ((Bignum)first).value;
......@@ -72,9 +72,9 @@ public final class logorc1 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.not().or(n2));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
return error(new TypeError(first, Symbol.INTEGER));
return type_error(first, Symbol.INTEGER);
}
private static final Primitive LOGORC1 = new logorc1();
......
......@@ -60,7 +60,7 @@ public final class logorc2 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.or(n2.not()));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
if (first instanceof Bignum) {
BigInteger n1 = ((Bignum)first).value;
......@@ -72,9 +72,9 @@ public final class logorc2 extends Primitive
BigInteger n2 = ((Bignum)second).value;
return number(n1.or(n2.not()));
}
return error(new TypeError(second, Symbol.INTEGER));
return type_error(second, Symbol.INTEGER);
}
return error(new TypeError(first, Symbol.INTEGER));
return type_error(first, Symbol.INTEGER);
}
private static final Primitive LOGORC2 = new logorc2();
......
......@@ -48,7 +48,7 @@ public final class unbound_slot_instance extends Primitive
{
if (arg instanceof UnboundSlot)
return ((UnboundSlot)arg).getInstance();
return error(new TypeError(arg, Symbol.UNBOUND_SLOT));
return type_error(arg, Symbol.UNBOUND_SLOT);
}
private static final unbound_slot_instance CELL_ERROR_NAME =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment