/** * Executes the Lua statement {@code table[key] = value}, 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. * * <p>This method differs from {@link #setindex(ExecutionContext, Object, Object, Object)} * in that the {@code table} argument is required to be a non-{@code null} reference * to a {@link Table}.</p> * * @param context execution context, must not be {@code null} * @param table the target, must not be {@code null} * @param key the key, may be any value * @param value the value, 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} or {@code table} is {@code null} */ @SuppressWarnings("unused") public static void setindex(ExecutionContext context, Table table, Object key, Object value) throws UnresolvedControlThrowable { // TODO: don't just delegate to the generic case setindex(context, (Object) Objects.requireNonNull(table), key, value); }
/** * Executes the Lua statement {@code table[key] = value}, 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. * * <p>This method differs from {@link #setindex(ExecutionContext, Object, Object, Object)} * in that the {@code table} argument is required to be a non-{@code null} reference * to a {@link Table}, and {@code key} is an unboxed {@code long}.</p> * * @param context execution context, must not be {@code null} * @param table the target, must not be {@code null} * @param key the integer key * @param value the value, 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} or {@code table} is {@code null} */ @SuppressWarnings("unused") public static void setindex(ExecutionContext context, Table table, long key, Object value) throws UnresolvedControlThrowable { // TODO: don't just delegate to the generic case setindex(context, (Object) Objects.requireNonNull(table), Long.valueOf(key), value); }
@Override public void invoke(ExecutionContext context, Object t, Object k, Object v) throws ResolvedControlThrowable { try { Dispatch.setindex(context, t, k, v); } catch (UnresolvedControlThrowable ct) { throw ct.resolve(this, null); } resume(context, null); }
private void _end(ExecutionContext context, int state, Table t, long pos, Object value) throws ResolvedControlThrowable { try { switch (state) { case _END_TABSET: state = _END_RETURN; Dispatch.setindex(context, t, pos, value); case _END_RETURN: break; default: throw new IllegalStateException("Illegal state: " + state); } } catch (UnresolvedControlThrowable ct) { throw ct.resolve(this, new SuspendedState(state, t, null, pos, -1, value)); } // finished! context.getReturnBuffer().setTo(); }
private void _erase(ExecutionContext context, int state, Table t, long idx, Object result) throws ResolvedControlThrowable { try { switch (state) { case _ERASE_PREPARE: state = _ERASE_RESUME; Dispatch.setindex(context, t, idx, null); case _ERASE_RESUME: // we're done break; default: throw new IllegalStateException("Illegal state: " + state); } } catch (UnresolvedControlThrowable ct) { // no need to carry any information but the result around throw ct.resolve(this, new SuspendedState(state, null, null, 0, 0, result)); } // finished, set the result context.getReturnBuffer().setTo(result); }
state = _LOOP_TEST; Object v = context.getReturnBuffer().get0(); Dispatch.setindex(context, t, k - 1, v); break; // go to next iteration
state = _LOOP_TEST; Object v = context.getReturnBuffer().get0(); Dispatch.setindex(context, t, k, v); break; // go to next iteration
Object v = context.getReturnBuffer().get0(); state = 3; Dispatch.setindex(context, a2, t + idx, v); case 3: idx += (asc ? 1 : -1);
setindex(context, handler, key, value);