/** * Evaluates the Lua expression {@code table[key]} (in non-assignment context) 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 #index(ExecutionContext, 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 table, must not be {@code null} * @param key the key, 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 index(ExecutionContext context, Table table, Object key) throws UnresolvedControlThrowable { // TODO: don't just delegate to the generic case index(context, (Object) Objects.requireNonNull(table), key); }
/** * Evaluates the Lua expression {@code table[key]} (in non-assignment context) 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 #index(ExecutionContext, 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 table, must not be {@code null} * @param key the integer key * * @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 index(ExecutionContext context, Table table, long key) throws UnresolvedControlThrowable { // TODO: don't just delegate to the generic case index(context, (Object) Objects.requireNonNull(table), Long.valueOf(key)); }
@Override public void invoke(ExecutionContext context, Object t, Object k) throws ResolvedControlThrowable { try { Dispatch.index(context, t, k); } catch (UnresolvedControlThrowable ct) { throw ct.resolve(this, null); } resume(context, null); }
private void nonStringReplace( ExecutionContext context, String str, StringPattern pat, int idx, int count, int num, StringBuilder bld, Object repl, String fullMatch, List<Object> captures) throws ResolvedControlThrowable { assert (!captures.isEmpty()); Object cap = captures.get(0); try { if (repl instanceof Table) { Dispatch.index(context, (Table) repl, cap); } else if (repl instanceof LuaFunction) { Dispatch.call(context, (LuaFunction) repl, (Object[]) captures.toArray()); } else { throw new IllegalStateException("Illegal replacement: " + repl); } } catch (UnresolvedControlThrowable ct) { throw ct.resolve(this, new State(str, pat, count, num, repl, bld, fullMatch, idx)); } resumeReplace(context, bld, fullMatch); }
Dispatch.index(context, t, k);
private void _get_result(ExecutionContext context, int state, Table t, long pos, long len) throws ResolvedControlThrowable { final Object result; try { switch (state) { case _GET_PREPARE: state = _GET_RESUME; Dispatch.index(context, t, pos); case _GET_RESUME: result = context.getReturnBuffer().get0(); break; default: throw new IllegalStateException("Illegal state: " + state); } } catch (UnresolvedControlThrowable ct) { throw ct.resolve(this, new SuspendedState(state, t, null, pos, len, null)); } if (pos == 0 || pos == len || pos == len + 1) { // erase t[pos] _erase(context, _ERASE_PREPARE, t, pos, result); } else { // pos now used for iteration; want (pos + 1), but it will be incremented before the test _loop(context, _LOOP_TEST, t, pos, len, result); } }
Dispatch.index(context, t, k - 1);
@Override protected void invoke(ExecutionContext context, ArgumentIterator args) throws ResolvedControlThrowable { Table table = args.nextTable(); long index = args.nextInteger(); index += 1; try { Dispatch.index(context, table, index); } catch (UnresolvedControlThrowable ct) { throw ct.resolve(this, index); } Object result = context.getReturnBuffer().get0(); processResult(context, index, result); }
Dispatch.index(context, a1, f + idx); case 2: Object v = context.getReturnBuffer().get0();
Dispatch.index(context, envTable, ToString.KEY);
index(context, handler, key);