Extract common integer check

(Olof-Joachim Frahm)
parent cdb6989c
......@@ -1082,7 +1082,14 @@ public final class Lisp
}
}
public static Symbol checkSymbol(LispObject obj)
public static final LispInteger checkInteger(LispObject obj) {
if (obj instanceof LispInteger)
return (LispInteger) obj;
return (LispInteger) // Not reached.
type_error(obj, Symbol.INTEGER);
}
public static final Symbol checkSymbol(LispObject obj)
{
if (obj instanceof Symbol)
return (Symbol) obj;
......
......@@ -54,9 +54,7 @@ public final class logand extends Primitive
@Override
public LispObject execute(LispObject arg)
{
if (arg instanceof Fixnum || arg instanceof Bignum)
return arg;
return type_error(arg, Symbol.INTEGER);
return checkInteger(arg);
}
@Override
......
......@@ -56,11 +56,7 @@ public final class logeqv extends Primitive
@Override
public LispObject execute(LispObject arg)
{
if (arg instanceof Fixnum)
return arg;
if (arg instanceof Bignum)
return arg;
return type_error(arg, Symbol.INTEGER);
return checkInteger(arg);
}
@Override
......
......@@ -52,9 +52,7 @@ public final class logior extends Primitive
@Override
public LispObject execute(LispObject arg)
{
if (arg instanceof Fixnum || arg instanceof Bignum)
return arg;
return type_error(arg, Symbol.INTEGER);
return checkInteger(arg);
}
@Override
......
......@@ -52,9 +52,7 @@ public final class logxor extends Primitive
@Override
public LispObject execute(LispObject arg)
{
if (arg instanceof Fixnum || arg instanceof Bignum)
return arg;
return type_error(arg, Symbol.INTEGER);
return checkInteger(arg);
}
@Override
......
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