Class BeforeConstant
java.lang.Object
org.spongepowered.asm.mixin.injection.InjectionPoint
org.spongepowered.asm.mixin.injection.points.BeforeConstant
Special injection point which can be defined by an
Constant
annotation 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 At it 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 shift
specifier 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
ConstructorsConstructorDescriptionBeforeConstant(IMixinContext context, org.objectweb.asm.tree.AnnotationNode node, String returnType) -
Method Summary
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 Details
-
BeforeConstant
public BeforeConstant(IMixinContext context, org.objectweb.asm.tree.AnnotationNode node, String returnType) -
BeforeConstant
-
-
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- 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
-