Class BeforeInvoke

  • Direct Known Subclasses:
    AfterInvoke, BeforeFieldAccess, BeforeStringInvoke

    public class BeforeInvoke
    extends InjectionPoint

    This injection point searches for INVOKEVIRTUAL, INVOKESTATIC and INVOKESPECIAL opcodes matching its arguments and returns a list of insns immediately prior to matching instructions. It accepts the following parameters from At:

    target
    A Target Selector which identifies the target method
    ordinal
    The ordinal position of the method invocation to match. For example if the method is invoked 3 times and you want to match the 3rd then you can specify an ordinal of 2 (ordinals are zero-indexed). The default value is -1 which supresses ordinal matching

    Example:

       @At(value = "INVOKE", target="func_1234_a(III)V")

    Note that like all standard injection points, this class matches the insn itself, putting the injection point immediately before the access in question. Use At.shift() specifier to adjust the matched opcode as necessary.

    • Field Detail

      • allowPermissive

        protected final boolean allowPermissive
        This option enables a fallback "permissive" search to occur if initial search fails if and only if the MixinEnvironment.Option.REFMAP_REMAP option is enabled and the context mixin's parent config has a valid refmap.
      • ordinal

        protected final int ordinal
        This strategy can be used to identify a particular invocation if the same method is invoked at multiple points, if this value is -1 then the strategy returns all invocations of the method.
      • className

        protected final java.lang.String className
        Class name (description) for debug logging
      • logger

        protected final ILogger logger
        Logger reference
    • Method Detail

      • setLogging

        public BeforeInvoke setLogging​(boolean logging)
        Set the logging state for this injector
        Parameters:
        logging - logging state
        Returns:
        fluent interface
      • find

        public boolean find​(java.lang.String desc,
                            org.objectweb.asm.tree.InsnList insns,
                            java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)
        Description copied from class: InjectionPoint
        Find injection points in the supplied insn list
        Specified by:
        find in class InjectionPoint
        Parameters:
        desc - Method descriptor, supplied to allow return types and arguments etc. to be determined
        insns - Insn list to search in, the strategy MUST ONLY add nodes from this list to the nodes collection
        nodes - Collection of nodes to populate. Injectors should NOT make any assumptions about the state of this collection and should only call the add() method
        Returns:
        true if one or more injection points were found
      • find

        protected boolean find​(java.lang.String desc,
                               org.objectweb.asm.tree.InsnList insns,
                               java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes,
                               ITargetSelector selector,
                               BeforeInvoke.SearchType searchType)
      • addInsn

        protected boolean addInsn​(org.objectweb.asm.tree.InsnList insns,
                                  java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes,
                                  org.objectweb.asm.tree.AbstractInsnNode insn)
      • matchesInsn

        protected boolean matchesInsn​(org.objectweb.asm.tree.AbstractInsnNode insn)
      • inspectInsn

        protected void inspectInsn​(java.lang.String desc,
                                   org.objectweb.asm.tree.InsnList insns,
                                   org.objectweb.asm.tree.AbstractInsnNode insn)
      • matchesOrdinal

        protected boolean matchesOrdinal​(int ordinal)
      • log

        protected void log​(java.lang.String message,
                           java.lang.Object... params)