Extract common integer check

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