Tabnine Logo
Binder.permute
Code IndexAdd Tabnine to your IDE (free)

How to use
permute
method
in
com.headius.invokebinder.Binder

Best Java code snippets using com.headius.invokebinder.Binder.permute (Showing top 20 results out of 315)

origin: org.projectodd.rephract/rephract

  public GuardBuilder permute(int... reorder) {
    binder = binder.permute(reorder);
    return this;
  }
}
origin: org.projectodd.rephract/rephract

public MultiBinder permute(int... reorder) {
  this.invokeBinder = invokeBinder.permute(reorder);
  this.guardBinder = guardBinder.permute(reorder);
  return this;
}
origin: com.headius/invokebinder

private Binder preparePermuteBinder(Permutes permutes) {
  return Binder.from(source)
      .permute(permutes.movePermute)
      .collect(source.parameterCount() - count, arrayType)
      .permute(permutes.moveBackPermute);
}
origin: org.projectodd.rephract/rephract

public GuardBuilder guard(int... reorder) {
  return new GuardBuilder(this, this.binder.guardBinder().permute(reorder));
}
origin: com.headius/invokebinder

/**
 * Using the argument names and order in the target Signature, permute the
 * arguments in this SmartBinder. Arguments may be duplicated or omitted
 * in the target Signature, but all arguments in the target must be defined
 * in this SmartBinder .
 *
 * @param target the Signature from which to derive a new argument list
 * @return a new SmartBinder with the permute applied
 */
public SmartBinder permute(Signature target) {
  return new SmartBinder(this, target, binder.permute(signature().to(target)));
}
origin: org.projectodd.rephract/rephract

@Override
public MethodHandle guardMethodHandle(MethodType inputType) throws NoSuchMethodException, IllegalAccessException {
  Binder binder = Binder.from(inputType);
  MethodHandle target = super.guardMethodHandle(methodType(boolean.class, this.argType));
  return binder.permute(this.argPos)
      .convert(target.type())
      .invoke(target);
}
origin: org.projectodd.rephract/rephract

@Override
public MethodHandle guardMethodHandle(MethodType inputType) throws NoSuchMethodException, IllegalAccessException {
  Binder binder = Binder.from(inputType);
  MethodHandle target = super.guardMethodHandle(methodType(boolean.class, this.argType));
  return binder.permute(this.argPos)
      .convert(target.type())
      .invoke(target);
}
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

Binder b = Binder
    .from(site.type())
    .permute(2, 3)
    .filterReturn(filter);
nativeTarget = Binder
    .from(site.type())
    .permute(2, 3)
    .filterReturn(filter)
    .insert(1, cls.getRealClass(), accessor.getIndex())
origin: com.ning.billing/killbill-osgi-bundles-jruby

Binder b = Binder
    .from(site.type())
    .permute(2, 3)
    .filterReturn(filter);
nativeTarget = Binder
    .from(site.type())
    .permute(2, 3)
    .filterReturn(filter)
    .insert(1, cls.getRealClass(), accessor.getIndex())
origin: com.ning.billing/killbill-osgi-bundles-jruby

Binder b = Binder
    .from(site.type())
    .permute(2)
    .filterReturn(filter);
nativeTarget = Binder
    .from(site.type())
    .permute(2)
    .filterReturn(filter)
    .insert(1, accessor.getIndex())
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

Binder b = Binder
    .from(site.type())
    .permute(2)
    .filterReturn(filter);
nativeTarget = Binder
    .from(site.type())
    .permute(2)
    .filterReturn(filter)
    .insert(1, accessor.getIndex())
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  @Override
  public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) {
    MethodHandle handle = ((HandleMethod)method).getHandle(site.arity());
    
    if (handle == null) {
      throw new IndirectBindingException("MH dynamic method does not have needed arity");
    }
    
    if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound from MHDynMethod " + logMethod(method) + ":" + handle);
    
    Signature fullSig = site.fullSignature();
    MethodHandle nativeTarget =  Binder
        .from(fullSig.type())
        .permute(fullSig.to("context", "self", "arg*", "block"))
        .invoke(handle);
    nativeTarget = addOrRemoveBlock(site, nativeTarget);
    
    return nativeTarget;            
  }
}
origin: com.ning.billing/killbill-osgi-bundles-jruby

  @Override
  public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) {
    MethodHandle handle = ((HandleMethod)method).getHandle(site.arity());
    
    if (handle == null) {
      throw new IndirectBindingException("MH dynamic method does not have needed arity");
    }
    
    if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound from MHDynMethod " + logMethod(method) + ":" + handle);
    
    Signature fullSig = site.fullSignature();
    MethodHandle nativeTarget =  Binder
        .from(fullSig.type())
        .permute(fullSig.to("context", "self", "arg*", "block"))
        .invoke(handle);
    nativeTarget = addOrRemoveBlock(site, nativeTarget);
    
    return nativeTarget;            
  }
}
origin: com.headius/invokebinder

private MethodHandle nativeTryFinally(MethodHandle target, MethodHandle post) {
  MethodType targetType = target.type();
  boolean voidReturn = targetType.returnType() == Void.TYPE;
  MethodType finallyType = targetType.insertParameterTypes(0, Throwable.class);
  int dropCount = 1;
  if (!voidReturn) {
    finallyType = finallyType.insertParameterTypes(1, targetType.returnType());
    dropCount = 2;
  }
  MethodHandle wrapPost = Binder
      .from(finallyType)
      .drop(0, dropCount)
      .invoke(post);
  if (!voidReturn) {
    wrapPost = Binder.from(finallyType)
        .foldVoid(wrapPost)
        .permute(1)
        .identity();
  }
  try {
    return (MethodHandle) tryFinallyJava9.invokeExact(target, wrapPost);
  } catch (Throwable t) {
    throw new RuntimeException("Java 9 detected but MethodHandles.tryFinally missing", t);
  }
}
origin: org.jruby/jruby-core

public static MethodHandle wrapWithFrameOnly(Signature signature, RubyModule implClass, String name, MethodHandle nativeTarget) {
  MethodHandle framePre = getFrameOnlyPre(signature, CallConfiguration.FrameFullScopeNone, implClass, name);
  MethodHandle framePost = getFramePost(signature, CallConfiguration.FrameFullScopeNone);
  // post logic for frame
  nativeTarget = Binder
      .from(nativeTarget.type())
      .tryFinally(framePost)
      .invoke(nativeTarget);
  // pre logic for frame
  nativeTarget = foldArguments(nativeTarget, framePre);
  // call polling and call number increment
  nativeTarget = Binder
      .from(nativeTarget.type())
      .fold(Binder
          .from(nativeTarget.type().changeReturnType(void.class))
          .permute(0)
          .invokeStaticQuiet(lookup(), ThreadContext.class, "callThreadPoll"))
      .invoke(nativeTarget);
  return nativeTarget;
}
origin: org.jruby/jruby-complete

public static MethodHandle wrapWithFrameOnly(Signature signature, RubyModule implClass, String name, MethodHandle nativeTarget) {
  MethodHandle framePre = getFrameOnlyPre(signature, CallConfiguration.FrameFullScopeNone, implClass, name);
  MethodHandle framePost = getFramePost(signature, CallConfiguration.FrameFullScopeNone);
  // post logic for frame
  nativeTarget = Binder
      .from(nativeTarget.type())
      .tryFinally(framePost)
      .invoke(nativeTarget);
  // pre logic for frame
  nativeTarget = foldArguments(nativeTarget, framePre);
  // call polling and call number increment
  nativeTarget = Binder
      .from(nativeTarget.type())
      .fold(Binder
          .from(nativeTarget.type().changeReturnType(void.class))
          .permute(0)
          .invokeStaticQuiet(lookup(), ThreadContext.class, "callThreadPoll"))
      .invoke(nativeTarget);
  return nativeTarget;
}
origin: org.jruby/jruby-complete

public static MethodHandle wrapWithFraming(Signature signature, CallConfiguration callConfig, RubyModule implClass, String name, MethodHandle nativeTarget, StaticScope scope) {
  MethodHandle framePre = getFramePre(signature, callConfig, implClass, name, scope);
  if (framePre != null) {
    MethodHandle framePost = getFramePost(signature, callConfig);
    // break, return, redo handling
    boolean heapScoped = callConfig.scoping() != Scoping.None;
    boolean framed = callConfig.framing() != Framing.None;
    // post logic for frame
    nativeTarget = Binder
        .from(nativeTarget.type())
        .tryFinally(framePost)
        .invoke(nativeTarget);
    // pre logic for frame
    nativeTarget = foldArguments(nativeTarget, framePre);
    // call polling and call number increment
    nativeTarget = Binder
        .from(nativeTarget.type())
        .fold(Binder
            .from(nativeTarget.type().changeReturnType(void.class))
            .permute(0)
            .invokeStaticQuiet(lookup(), ThreadContext.class, "callThreadPoll"))
        .invoke(nativeTarget);
  }
  return nativeTarget;
}
origin: org.jruby/jruby-core

public static MethodHandle wrapWithFraming(Signature signature, CallConfiguration callConfig, RubyModule implClass, String name, MethodHandle nativeTarget, StaticScope scope) {
  MethodHandle framePre = getFramePre(signature, callConfig, implClass, name, scope);
  if (framePre != null) {
    MethodHandle framePost = getFramePost(signature, callConfig);
    // break, return, redo handling
    boolean heapScoped = callConfig.scoping() != Scoping.None;
    boolean framed = callConfig.framing() != Framing.None;
    // post logic for frame
    nativeTarget = Binder
        .from(nativeTarget.type())
        .tryFinally(framePost)
        .invoke(nativeTarget);
    // pre logic for frame
    nativeTarget = foldArguments(nativeTarget, framePre);
    // call polling and call number increment
    nativeTarget = Binder
        .from(nativeTarget.type())
        .fold(Binder
            .from(nativeTarget.type().changeReturnType(void.class))
            .permute(0)
            .invokeStaticQuiet(lookup(), ThreadContext.class, "callThreadPoll"))
        .invoke(nativeTarget);
  }
  return nativeTarget;
}
origin: org.jruby/jruby-complete

public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Throwable {
  if (Options.INVOKEDYNAMIC_YIELD.load()) {
    BlockBody body = block.getBody();
    MethodHandle target;
    if (block.getBody() instanceof CompiledIRBlockBody) {
      CompiledIRBlockBody compiledBody = (CompiledIRBlockBody) block.getBody();
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound directly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = compiledBody.getNormalYieldSpecificHandle();
    } else {
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound indirectly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = Binder.from(type())
          .permute(1, 0)
          .invokeVirtualQuiet(MethodHandles.lookup(), "yieldSpecific");
    }
    MethodHandle fallback = getTarget();
    MethodHandle test = body.getTestBlockBody();
    MethodHandle guard = MethodHandles.guardWithTest(test, target, fallback);
    setTarget(guard);
    return (IRubyObject) target.invokeExact(context, block);
  }
  return block.yieldSpecific(context);
}
origin: org.jruby/jruby-core

public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Throwable {
  if (Options.INVOKEDYNAMIC_YIELD.load()) {
    BlockBody body = block.getBody();
    MethodHandle target;
    if (block.getBody() instanceof CompiledIRBlockBody) {
      CompiledIRBlockBody compiledBody = (CompiledIRBlockBody) block.getBody();
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound directly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = compiledBody.getNormalYieldSpecificHandle();
    } else {
      if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
        LOG.info("yield \tbound indirectly as yieldSpecific:" + Bootstrap.logBlock(block));
      }
      target = Binder.from(type())
          .permute(1, 0)
          .invokeVirtualQuiet(MethodHandles.lookup(), "yieldSpecific");
    }
    MethodHandle fallback = getTarget();
    MethodHandle test = body.getTestBlockBody();
    MethodHandle guard = MethodHandles.guardWithTest(test, target, fallback);
    setTarget(guard);
    return (IRubyObject) target.invokeExact(context, block);
  }
  return block.yieldSpecific(context);
}
com.headius.invokebinderBinderpermute

Javadoc

Permute the incoming arguments to a new sequence specified by the given values. Arguments may be duplicated or dropped in this sequence.

Popular methods of Binder

  • from
    Construct a new Binder, starting from a given MethodType.
  • insert
    Insert at the given index the given argument value(s).
  • invoke
    Apply the chain of transforms and bind them to a static method specified using the end signature plu
  • collect
    Box all incoming arguments from the given position onward into the given array type.
  • constant
    Apply the tranforms, binding them to a constant value that will propagate back through the chain. Th
  • drop
    Drop from the given index a number of arguments.
  • filter
    Filter incoming arguments, from the given index, replacing each with the result of calling the assoc
  • fold
    Process the incoming arguments using the given handle, inserting the result as the first argument.
  • invokeVirtual
    Apply the chain of transforms and bind them to a virtual method specified using the end signature pl
  • cast
    Cast the incoming arguments to the given MethodType. The casts applied are equivalent to those in Me
  • filterReturn
    Filter return value, using a function that produces the current return type from another type. The n
  • invokeStaticQuiet
    Apply the chain of transforms and bind them to a static method specified using the end signature plu
  • filterReturn,
  • invokeStaticQuiet,
  • invokeVirtualQuiet,
  • tryFinally,
  • nop,
  • type,
  • append,
  • foldVoid,
  • identity

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSharedPreferences (Context)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now