Class BeforeStringInvoke
Like BeforeInvoke, this injection point searches for
INVOKEVIRTUAL, INVOKESTATIC and INVOKESPECIAL opcodes matching its arguments
and returns a list of insns immediately prior to matching instructions. This
specialised version however only matches methods which accept a single string
and return void, but allows the string itself to be matched as part of the
search process. This is primarily used for matching particular invocations of
Profiler::startSection with a specific argument. Note that because a
string literal is required, this injection point can not be used to match
invocations where the value being passed in is a variable.
To be precise, this injection point matches invocations of the specified method which are preceded by an LDC instruction. The LDC instruction's payload can be specified with the ldc named argument (see below)
The following parameters from
At are accepted
- target
- A
Target Selectorwhich identifies the target method, the method must be specified with a signature which accepts a single string and returns void, eg.(Ljava/lang/String;)V - 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
- named argument: ldc
- The value of the LDC node to look for prior to the method invocation
Example:
@At(value = "INVOKE_STRING",
target="startSection(Ljava/lang/String;)V", args = { "ldc=root" })
Notice the use of the named argument "ldc" which specifies the value of the target LDC node.
Note that like all standard injection points, this class matches the insn
itself, putting the injection point immediately before the access in
question. Use shift
specifier to adjust the matched opcode as necessary.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.spongepowered.asm.mixin.injection.points.BeforeInvoke
BeforeInvoke.SearchTypeNested classes/interfaces inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
InjectionPoint.AtCode, InjectionPoint.Flags, InjectionPoint.RestrictTargetLevel, InjectionPoint.Specifier -
Field Summary
Fields inherited from class org.spongepowered.asm.mixin.injection.points.BeforeInvoke
allowPermissive, className, context, logger, mixin, ordinal, targetFields inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
DEFAULT_ALLOWED_SHIFT_BY, MAX_ALLOWED_SHIFT_BY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfind(String desc, org.objectweb.asm.tree.InsnList insns, Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes) Find injection points in the supplied insn listprotected voidinspectInsn(String desc, org.objectweb.asm.tree.InsnList insns, org.objectweb.asm.tree.AbstractInsnNode insn) protected booleanmatchesOrdinal(int ordinal) Methods inherited from class org.spongepowered.asm.mixin.injection.points.BeforeInvoke
addInsn, find, log, matchesInsn, setLoggingMethods inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
addMessage, after, and, before, checkPriority, getAtCode, getId, getSlice, getSpecifier, getTargetRestriction, nextNode, or, parse, parse, parse, parse, parse, parse, parse, parse, register, register, setTargetRestriction, shift, toString
-
Constructor Details
-
BeforeStringInvoke
-
-
Method Details
-
find
public boolean find(String desc, org.objectweb.asm.tree.InsnList insns, Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes) Description copied from class:InjectionPointFind injection points in the supplied insn list- Overrides:
findin classBeforeInvoke- Parameters:
desc- Method descriptor, supplied to allow return types and arguments etc. to be determinedinsns- Insn list to search in, the strategy MUST ONLY add nodes from this list to thenodescollectionnodes- 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
-
inspectInsn
protected void inspectInsn(String desc, org.objectweb.asm.tree.InsnList insns, org.objectweb.asm.tree.AbstractInsnNode insn) - Overrides:
inspectInsnin classBeforeInvoke
-
matchesOrdinal
protected boolean matchesOrdinal(int ordinal) - Overrides:
matchesOrdinalin classBeforeInvoke
-