/** * Evaluates the Lua expression {@code -a}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param o the argument, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code o} does not have an arithmetic value * and does not have the {@code __unm} metamethod */ @SuppressWarnings("unused") public static void unm(ExecutionContext context, Object o) throws UnresolvedControlThrowable { Number no = Conversions.arithmeticValueOf(o); Arithmetic m = Arithmetic.of(no); if (m != null) { context.getReturnBuffer().setTo(m.unm(no)); } else { try_mt_arithmetic(context, Metatables.MT_UNM, o); } }
/** * Evaluates the Lua expression {@code a + b}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param a the first operand, may be any value * @param b the second operand, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code a} or {@code b} does not have * an arithmetic value and neither {@code a} nor * {@code b} has the {@code __add} metamethod */ @SuppressWarnings("unused") public static void add(ExecutionContext context, Object a, Object b) throws UnresolvedControlThrowable { Number na = Conversions.arithmeticValueOf(a); Number nb = Conversions.arithmeticValueOf(b); Arithmetic math = Arithmetic.of(na, nb); if (math != null) { context.getReturnBuffer().setTo(math.add(na, nb)); } else { try_mt_arithmetic(context, Metatables.MT_ADD, a, b); } }
/** * Evaluates the Lua expression {@code a % b}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param a the first operand, may be any value * @param b the second operand, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code a} or {@code b} does not have * an arithmetic value and neither {@code a} nor * {@code b} has the {@code __mod} metamethod */ @SuppressWarnings("unused") public static void mod(ExecutionContext context, Object a, Object b) throws UnresolvedControlThrowable { Number na = Conversions.arithmeticValueOf(a); Number nb = Conversions.arithmeticValueOf(b); Arithmetic m = Arithmetic.of(na, nb); if (m != null) { context.getReturnBuffer().setTo(m.mod(na, nb)); } else { try_mt_arithmetic(context, Metatables.MT_MOD, a, b); } }
/** * Evaluates the Lua expression {@code a - b}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param a the first operand, may be any value * @param b the second operand, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code a} or {@code b} does not have * an arithmetic value and neither {@code a} nor * {@code b} has the {@code __sub} metamethod */ @SuppressWarnings("unused") public static void sub(ExecutionContext context, Object a, Object b) throws UnresolvedControlThrowable { Number na = Conversions.arithmeticValueOf(a); Number nb = Conversions.arithmeticValueOf(b); Arithmetic m = Arithmetic.of(na, nb); if (m != null) { context.getReturnBuffer().setTo(m.sub(na, nb)); } else { try_mt_arithmetic(context, Metatables.MT_SUB, a, b); } }
/** * Evaluates the Lua expression {@code a * b}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param a the first operand, may be any value * @param b the second operand, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code a} or {@code b} does not have * an arithmetic value and neither {@code a} nor * {@code b} has the {@code __mul} metamethod */ @SuppressWarnings("unused") public static void mul(ExecutionContext context, Object a, Object b) throws UnresolvedControlThrowable { Number na = Conversions.arithmeticValueOf(a); Number nb = Conversions.arithmeticValueOf(b); Arithmetic m = Arithmetic.of(na, nb); if (m != null) { context.getReturnBuffer().setTo(m.mul(na, nb)); } else { try_mt_arithmetic(context, Metatables.MT_MUL, a, b); } }
/** * Evaluates the Lua expression {@code a / b}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param a the first operand, may be any value * @param b the second operand, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code a} or {@code b} does not have * an arithmetic value and neither {@code a} nor * {@code b} has the {@code __div} metamethod */ @SuppressWarnings("unused") public static void div(ExecutionContext context, Object a, Object b) throws UnresolvedControlThrowable { Number na = Conversions.arithmeticValueOf(a); Number nb = Conversions.arithmeticValueOf(b); Arithmetic m = Arithmetic.of(na, nb); if (m != null) { context.getReturnBuffer().setTo(m.div(na, nb)); } else { try_mt_arithmetic(context, Metatables.MT_DIV, a, b); } }
/** * Evaluates the Lua expression {@code a // b}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param a the first operand, may be any value * @param b the second operand, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code a} or {@code b} does not have * an arithmetic value and neither {@code a} nor * {@code b} has the {@code __idiv} metamethod */ @SuppressWarnings("unused") public static void idiv(ExecutionContext context, Object a, Object b) throws UnresolvedControlThrowable { Number na = Conversions.arithmeticValueOf(a); Number nb = Conversions.arithmeticValueOf(b); Arithmetic m = Arithmetic.of(na, nb); if (m != null) { context.getReturnBuffer().setTo(m.idiv(na, nb)); } else { try_mt_arithmetic(context, Metatables.MT_IDIV, a, b); } }
/** * Evaluates the Lua expression {@code a ^ b}, including the handling of metamethods, * and stores the result to the return buffer associated with {@code context}. * <b>This method throws an {@link UnresolvedControlThrowable}</b>: non-local control * changes are expected to be resolved by the caller of this method. * * @param context execution context, must not be {@code null} * @param a the first operand, may be any value * @param b the second operand, may be any value * * @throws UnresolvedControlThrowable if the evaluation called a metamethod and the metamethod * initiates a non-local control change * @throws NullPointerException if {@code context} is {@code null} * @throws IllegalOperationAttemptException if {@code a} or {@code b} does not have * an arithmetic value and neither {@code a} nor * {@code b} has the {@code __pow} metamethod */ @SuppressWarnings("unused") public static void pow(ExecutionContext context, Object a, Object b) throws UnresolvedControlThrowable { Number na = Conversions.arithmeticValueOf(a); Number nb = Conversions.arithmeticValueOf(b); Arithmetic m = Arithmetic.of(na, nb); if (m != null) { context.getReturnBuffer().setTo(m.pow(na, nb)); } else { try_mt_arithmetic(context, Metatables.MT_POW, a, b); } }