public void loadSelf() { adapter.aload(signature.argOffset("self")); }
public void loadContext() { adapter.aload(signature.argOffset("context")); }
public void storeArgs() { adapter.astore(signature.argOffset("args")); }
/** * Insert arguments (names + types) into the signature before the argument * with the given name. * * @param beforeName the name of the argument before which to insert * @param names the names of the new arguments * @param types the types of the new arguments * @return a new Signature with the added arguments */ public Signature insertArgs(String beforeName, String[] names, Class<?>... types) { return insertArgs(argOffset(beforeName), names, types); }
public void loadBlock() { adapter.aload(signature.argOffset(JVMVisitor.BLOCK_ARG_NAME)); }
public void storeArgs() { adapter.astore(signature.argOffset("args")); }
/** * Insert an argument (name + type) into the signature before the argument * with the given name. * * @param beforeName the name of the argument before which to insert * @param name the name of the new argument * @param type the type of the new argument * @return a new signature with the added arguments */ public Signature insertArg(String beforeName, String name, Class<?> type) { return insertArgs(argOffset(beforeName), new String[]{name}, new Class<?>[]{type}); }
public void loadSelf() { adapter.aload(signature.argOffset("self")); }
public void loadStaticScope() { adapter.aload(signature.argOffset("scope")); }
public void loadStaticScope() { adapter.aload(signature.argOffset("scope")); }
public void loadSelfBlock() { int selfBlockOffset = signature.argOffset(JVMVisitor.SELF_BLOCK_NAME); if (selfBlockOffset == -1) { adapter.aconst_null(); } else { adapter.aload(selfBlockOffset); } }
public void loadSelfBlock() { int selfBlockOffset = signature.argOffset(JVMVisitor.SELF_BLOCK_NAME); if (selfBlockOffset == -1) { adapter.aconst_null(); } else { adapter.aload(selfBlockOffset); } }
/** * Drop an argument name and type from the handle at the given index, returning a new * SmartHandle. * * @param beforeName name before which the dropped argument goes * @param newName name of the argument * @param type type of the argument * @return a new SmartHandle with the additional argument */ public SmartHandle drop(String beforeName, String newName, Class<?> type) { return new SmartHandle(signature.insertArg(beforeName, newName, type), MethodHandles.dropArguments(handle, signature.argOffset(beforeName), type)); }
/** * Drop an argument from the handle at the end, returning a new * SmartHandle. * * @param newName name of the argument * @param type type of the argument * @return a new SmartHandle with the additional argument */ public SmartHandle dropLast(String newName, Class<?> type) { return new SmartHandle(signature.appendArg(newName, type), MethodHandles.dropArguments(handle, signature.argOffset(newName), type)); }
/** * Apply an argument into the handle at the given name, returning a new * SmartHandle. The new handle will use the given value for the argument at * the given index, accepting one fewer argument as a result. In other words, * fix that argument (partial application) into the given handle. * * @param name the name of the argument in the new SmartHandle's Signature * @param arg the argument value * @return a new SmartHandle that already has applied the given argument */ public SmartHandle apply(String name, Object arg) { return new SmartHandle(signature.dropArg(name), MethodHandles.insertArguments(handle, signature.argOffset(name), arg)); }
/** * Drop the argument with the given name. * * @param name the name of the argument to drop * @return a new SmartBinder with the drop applied */ public SmartBinder drop(String name) { int index = signature().argOffset(name); return new SmartBinder(this, signature().dropArg(index), binder.drop(index)); }
public void loadFrameName() { int superNameOffset = signature.argOffset(JVMVisitor.SUPER_NAME_NAME); if (superNameOffset == -1) { // load from self block loadSelfBlock(); adapter.invokevirtual(p(Block.class), "getBinding", sig(Binding.class)); adapter.invokevirtual(p(Binding.class), "getMethod", sig(String.class)); } else { adapter.aload(superNameOffset); } }
public void loadFrameName() { int superNameOffset = signature.argOffset(JVMVisitor.SUPER_NAME_NAME); if (superNameOffset == -1) { // load from self block loadSelfBlock(); adapter.invokevirtual(p(Block.class), "getBinding", sig(Binding.class)); adapter.invokevirtual(p(Binding.class), "getMethod", sig(String.class)); } else { adapter.aload(superNameOffset); } }
@Override public void ReceivePreReqdArgInstr(ReceivePreReqdArgInstr instr) { if (jvm.methodData().specificArity >= 0 && instr.getArgIndex() < jvm.methodData().specificArity) { jvmAdapter().aload(jvm.methodData().signature.argOffset("arg" + instr.getArgIndex())); } else { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.getArgIndex()); jvmMethod().invokeIRHelper("getPreArgSafe", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class)); } jvmStoreLocal(instr.getResult()); }
@Override public void ReceivePreReqdArgInstr(ReceivePreReqdArgInstr instr) { if (jvm.methodData().specificArity >= 0 && instr.getArgIndex() < jvm.methodData().specificArity) { jvmAdapter().aload(jvm.methodData().signature.argOffset("arg" + instr.getArgIndex())); } else { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.getArgIndex()); jvmMethod().invokeIRHelper("getPreArgSafe", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class)); } jvmStoreLocal(instr.getResult()); }