@Override
public Token eval(AbstractClass<?> caller, Token first, Token last, AbstractFrame frame) throws ArrayIndexOutOfBoundsException, IllegalArgumentException, InterpreterException {
if (data.equals("!")) {
Variable<?> value = (Variable<?>) last.getCar();
if (!value.getType().equals(Interpreter.booleanClass))
throw new UnexpectedTypeException("The logical inverse operation, !, is not valid for the type, " + value.getType());
return new Token(new PrimitiveObject<>(Interpreter.booleanClass, !((PrimitiveObject<Boolean>) value).getSource()), Interpreter.booleanType);
}
if (!last.getCarType().equals(Interpreter.identifierType))
throw new UnexpectedTypeException("The type, " + last.getCarType() + ", is not compatible with the " + data + " operation.");
AbstractObject<?> val = (AbstractObject<?>) frame.readVariable((String) last.getCar()).getCar();
if (!Interpreter.isNumber(val.getType()) && !val.getType().equals(Interpreter.characterClass))
throw new UnexpectedTypeException("The type, " + val.getType() + ", is not compatible with the " + data + " operation.");
PrimitiveObject<?> value = (PrimitiveObject<?>) val;
Token result = null;
if (data.equals("++")) {
PrimitiveObject<?>[] p = Interpreter.castPrimitives(value, new PrimitiveObject<>(Interpreter.integerClass, 1));
value.write(value.getType().makePrimitiveObject(p[0].getType().narrow(p[0].getType().add(p[0].getSource(), p[1].getSource()), value.getType())));