Class BeforeConstant
- java.lang.Object
-
- org.spongepowered.asm.mixin.injection.InjectionPoint
-
- org.spongepowered.asm.mixin.injection.points.BeforeConstant
-
public class BeforeConstant extends InjectionPoint
Special injection point which can be defined by anConstantannotation or using the at code CONSTANT.This injection point searches for LDC and other constant opcodes matching its arguments and returns a list of injection points matching those instructions. When used with
Atit accepts the following parameters:- ordinal
- The ordinal position of the constant opcode to match. The default value is -1 which supresses ordinal matching
- named argument: nullValue
- To match null literals in the method body, set this to true
- named argument: intValue
- To match int literals in the method body. See also the expandZeroConditions argument below for concerns when matching conditional zeroes.
- named argument: floatValue
- To match float literals in the method body.
- named argument: longValue
- To match long literals in the method body.
- named argument: doubleValue
- To match double literals in the method body.
- named argument: stringValue
- To match
Stringliterals in the method body. - named argument: classValue
- To match
Classliterals in the method body. - named argument: log
- Enable debug logging when searching for matching opcodes.
- named argument: expandZeroConditions
- See the
Constant.expandZeroConditions()option, this argument should be a list ofConstant.Conditionnames
Examples:
// Find all integer constans with value 4@At(value = "CONSTANT", args = "intValue=4")// Find the String literal "foo"@At(value = "CONSTANT", args = "stringValue=foo"// Find integer constants with value 0 and expand conditionals@At( value = "CONSTANT", args = { "intValue=0", "expandZeroConditions=LESS_THAN_ZERO,GREATER_THAN_ZERO" } )Note that like all standard injection points, this class matches the insn itself, putting the injection point immediately before the access in question. Use
shiftspecifier to adjust the matched opcode as necessary.
-
-
Nested Class Summary
-
Nested 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.InjectionPoint
DEFAULT_ALLOWED_SHIFT_BY, MAX_ALLOWED_SHIFT_BY
-
-
Constructor Summary
Constructors Constructor Description BeforeConstant(InjectionPointData data)BeforeConstant(IMixinContext context, org.objectweb.asm.tree.AnnotationNode node, java.lang.String returnType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanfind(java.lang.String desc, org.objectweb.asm.tree.InsnList insns, java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)Find injection points in the supplied insn listprotected voidlog(java.lang.String message, java.lang.Object... params)-
Methods 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 Detail
-
BeforeConstant
public BeforeConstant(IMixinContext context, org.objectweb.asm.tree.AnnotationNode node, java.lang.String returnType)
-
BeforeConstant
public BeforeConstant(InjectionPointData data)
-
-
Method Detail
-
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:InjectionPointFind injection points in the supplied insn list- Specified by:
findin classInjectionPoint- 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
-
log
protected void log(java.lang.String message, java.lang.Object... params)
-
-