public abstract class InjectionPoint
extends java.lang.Object
Base class for injection point discovery classes. Each subclass describes
a strategy for locating code injection points within a method, with the
find(java.lang.String, org.objectweb.asm.tree.InsnList, java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode>) method populating a collection with insn nodes from the method
which satisfy its strategy.
This base class also contains composite strategy factory methods such as
and(org.spongepowered.asm.mixin.injection.InjectionPoint...) and or(org.spongepowered.asm.mixin.injection.InjectionPoint...) which allow strategies to be combined using
intersection (and) or union (or) relationships to allow multiple strategies
to be easily combined.
You are free to create your own injection point subclasses, but take note
that it is allowed for a single InjectionPoint instance to be used for
multiple injections and thus implementing classes MUST NOT cache the insn
list, event, or nodes instance passed to the find(java.lang.String, org.objectweb.asm.tree.InsnList, java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode>) method, as each
call to find(java.lang.String, org.objectweb.asm.tree.InsnList, java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode>) must be considered a separate functional contract and
the InjectionPoint's lifespan is not linked to the discovery lifespan,
therefore it is important that the InjectionPoint implementation is fully
stateless.
| Modifier and Type | Class and Description |
|---|---|
static interface |
InjectionPoint.AtCode
Injection point code for
At annotations to use |
static class |
InjectionPoint.RestrictTargetLevel
Target restriction level for different injection point types when used
by restricted injectors (eg.
|
static class |
InjectionPoint.Selector
Selector type for slice delmiters, ignored for normal injection points.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_ALLOWED_SHIFT_BY
Initial limit on the value of
At.by() which triggers warning/error
(based on environment) |
static int |
MAX_ALLOWED_SHIFT_BY
Hard limit on the value of
At.by() which triggers error |
| Modifier | Constructor and Description |
|---|---|
protected |
InjectionPoint() |
protected |
InjectionPoint(InjectionPointData data) |
|
InjectionPoint(java.lang.String slice,
InjectionPoint.Selector selector,
java.lang.String id) |
| Modifier and Type | Method and Description |
|---|---|
static InjectionPoint |
after(InjectionPoint point)
Returns an injection point which returns all insns immediately following
insns from the supplied injection point
|
static InjectionPoint |
and(InjectionPoint... operands)
Returns a composite injection point which returns the intersection of
nodes from all component injection points
|
static InjectionPoint |
before(InjectionPoint point)
Returns an injection point which returns all insns immediately prior to
insns from the supplied injection point
|
boolean |
checkPriority(int targetPriority,
int mixinPriority)
Runs a priority check in the context of this injection point.
|
abstract boolean |
find(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 list
|
protected java.lang.String |
getAtCode() |
java.lang.String |
getId() |
InjectionPoint.Selector |
getSelector() |
java.lang.String |
getSlice() |
InjectionPoint.RestrictTargetLevel |
getTargetRestriction(IInjectionPointContext context)
Returns the target restriction level for this injection point.
|
protected static org.objectweb.asm.tree.AbstractInsnNode |
nextNode(org.objectweb.asm.tree.InsnList insns,
org.objectweb.asm.tree.AbstractInsnNode insn)
Get the insn immediately following the specified insn, or return the same
insn if the insn is the last insn in the list
|
static InjectionPoint |
or(InjectionPoint... operands)
Returns a composite injection point which returns the union of nodes from
all component injection points
|
static InjectionPoint |
parse(IInjectionPointContext owner,
org.objectweb.asm.tree.AnnotationNode node)
Parse an InjectionPoint from the supplied
At annotation supplied
as an AnnotationNode instance |
static InjectionPoint |
parse(IInjectionPointContext owner,
At at)
Parse an InjectionPoint from the supplied
At annotation |
static java.util.List<InjectionPoint> |
parse(IInjectionPointContext owner,
java.util.List<org.objectweb.asm.tree.AnnotationNode> ats)
Parse a collection of InjectionPoints from the supplied
At
annotations |
static InjectionPoint |
parse(IMixinContext context,
org.objectweb.asm.tree.MethodNode method,
org.objectweb.asm.tree.AnnotationNode parent,
org.objectweb.asm.tree.AnnotationNode node)
Parse an InjectionPoint from the supplied
At annotation supplied
as an AnnotationNode instance |
static InjectionPoint |
parse(IMixinContext context,
org.objectweb.asm.tree.MethodNode method,
org.objectweb.asm.tree.AnnotationNode parent,
At at)
Parse an InjectionPoint from the supplied
At annotation |
static java.util.List<InjectionPoint> |
parse(IMixinContext context,
org.objectweb.asm.tree.MethodNode method,
org.objectweb.asm.tree.AnnotationNode parent,
java.util.List<org.objectweb.asm.tree.AnnotationNode> ats)
Parse a collection of InjectionPoints from the supplied
At
annotations |
static InjectionPoint |
parse(IMixinContext context,
org.objectweb.asm.tree.MethodNode method,
org.objectweb.asm.tree.AnnotationNode parent,
java.lang.String at,
At.Shift shift,
int by,
java.util.List<java.lang.String> args,
java.lang.String target,
java.lang.String slice,
int ordinal,
int opcode,
java.lang.String id)
Parse and instantiate an InjectionPoint from the supplied information.
|
static void |
register(java.lang.Class<? extends InjectionPoint> type)
Register an injection point class.
|
static InjectionPoint |
shift(InjectionPoint point,
int count)
Returns an injection point which returns all insns offset by the
specified "count" from insns from the supplied injection point
|
java.lang.String |
toString() |
public static final int DEFAULT_ALLOWED_SHIFT_BY
At.by() which triggers warning/error
(based on environment)public static final int MAX_ALLOWED_SHIFT_BY
At.by() which triggers errorprotected InjectionPoint()
protected InjectionPoint(InjectionPointData data)
public InjectionPoint(java.lang.String slice,
InjectionPoint.Selector selector,
java.lang.String id)
public java.lang.String getSlice()
public InjectionPoint.Selector getSelector()
public java.lang.String getId()
public boolean checkPriority(int targetPriority,
int mixinPriority)
targetPriority - Priority of the mixin which originally merged the
target method in questionmixinPriority - Priority of the mixin which owns the owning injectorpublic InjectionPoint.RestrictTargetLevel getTargetRestriction(IInjectionPointContext context)
CallbackInjector).context - injection-specific contextpublic abstract boolean find(java.lang.String desc,
org.objectweb.asm.tree.InsnList insns,
java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)
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 the nodes collectionnodes - Collection of nodes to populate. Injectors should NOT make
any assumptions about the state of this collection and should only
call the add() methodpublic java.lang.String toString()
toString in class java.lang.Objectprotected static org.objectweb.asm.tree.AbstractInsnNode nextNode(org.objectweb.asm.tree.InsnList insns,
org.objectweb.asm.tree.AbstractInsnNode insn)
insns - Insn list to fetch frominsn - Insn nodepublic static InjectionPoint and(InjectionPoint... operands)
operands - injection points to perform intersectionpublic static InjectionPoint or(InjectionPoint... operands)
operands - injection points to perform unionpublic static InjectionPoint after(InjectionPoint point)
point - injection points to perform shiftpublic static InjectionPoint before(InjectionPoint point)
point - injection points to perform shiftpublic static InjectionPoint shift(InjectionPoint point, int count)
point - injection points to perform shiftcount - amount to shift bypublic static java.util.List<InjectionPoint> parse(IInjectionPointContext owner, java.util.List<org.objectweb.asm.tree.AnnotationNode> ats)
At
annotationsowner - Data for the mixin containing the annotation, used to obtain
the refmap, amongst other thingsats - At annotations to parse information frompublic static java.util.List<InjectionPoint> parse(IMixinContext context, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode parent, java.util.List<org.objectweb.asm.tree.AnnotationNode> ats)
At
annotationscontext - Data for the mixin containing the annotation, used to
obtain the refmap, amongst other thingsmethod - The annotated handler methodparent - The parent annotation which owns this At annotationats - At annotations to parse information frompublic static InjectionPoint parse(IInjectionPointContext owner, At at)
At annotationowner - Data for the mixin containing the annotation, used to obtain
the refmap, amongst other thingsat - At annotation to parse information frompublic static InjectionPoint parse(IMixinContext context, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode parent, At at)
At annotationcontext - Data for the mixin containing the annotation, used to
obtain the refmap, amongst other thingsmethod - The annotated handler methodparent - The parent annotation which owns this At annotationat - At annotation to parse information frompublic static InjectionPoint parse(IInjectionPointContext owner, org.objectweb.asm.tree.AnnotationNode node)
At annotation supplied
as an AnnotationNode instanceowner - Data for the mixin containing the annotation, used to obtain
the refmap, amongst other thingsnode - At annotation to parse information frompublic static InjectionPoint parse(IMixinContext context, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode parent, org.objectweb.asm.tree.AnnotationNode node)
At annotation supplied
as an AnnotationNode instancecontext - Data for the mixin containing the annotation, used to
obtain the refmap, amongst other thingsmethod - The annotated handler methodparent - The parent annotation which owns this At annotationnode - At annotation to parse information frompublic static InjectionPoint parse(IMixinContext context, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode parent, java.lang.String at, At.Shift shift, int by, java.util.List<java.lang.String> args, java.lang.String target, java.lang.String slice, int ordinal, int opcode, java.lang.String id)
context - Data for the mixin containing the annotation, used to
obtain the refmap, amongst other thingsmethod - The annotated handler methodparent - The parent annotation which owns this At annotationat - Injection point specifiershift - Shift type to applyby - Amount of shift to apply for the BY shift typeargs - Named parameterstarget - Target for supported injection pointsslice - Slice id for injectors which support multiple slicesordinal - Ordinal offset for supported injection pointsopcode - Bytecode opcode for supported injection pointsid - Injection point id from annotationprotected java.lang.String getAtCode()
public static void register(java.lang.Class<? extends InjectionPoint> type)
InjectionPoint.AtCode annotation for registration purposes.type - injection point type to register