Class LocalVariableDiscriminator
java.lang.Object
org.spongepowered.asm.mixin.injection.modify.LocalVariableDiscriminator
Encapsulates logic for identifying a local variable in a target method using
3 criteria: ordinal, index and name. This is used
by the
ModifyVariableInjector and its associated injection points.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDiscriminator context information, wraps all relevant information about a target location for use when performing discrimination -
Constructor Summary
ConstructorsConstructorDescriptionLocalVariableDiscriminator(boolean argsOnly, int ordinal, int index, Set<String> names, boolean print) -
Method Summary
Modifier and TypeMethodDescriptionintFind a local variable for the specified contextintgetIndex()Get the local variable absolute indexgetNames()Get valid names for considerationintGet the local variable ordinal (nth variable of type)booleanhasNames()Returns true if names is not emptybooleanTrue if this discriminator will examine only the target method args and won't consider the rest of the LVT at the target locationprotected booleanIf the user specifies no values for ordinal, index or names then we are considered to be operating in "implicit mode" where only a single local variable of the specified type is expected to exist.static LocalVariableDiscriminatorparse(org.objectweb.asm.tree.AnnotationNode annotation) Parse a local variable discriminator from the supplied annotationbooleanprintLVT()True if the injector should print the LVTtoString()
-
Constructor Details
-
LocalVariableDiscriminator
public LocalVariableDiscriminator(boolean argsOnly, int ordinal, int index, Set<String> names, boolean print) - Parameters:
argsOnly- true to only search within the method argumentsordinal- target variable ordinalindex- target variable indexnames- target variable namesprint- true to print lvt
-
-
Method Details
-
isArgsOnly
public boolean isArgsOnly()True if this discriminator will examine only the target method args and won't consider the rest of the LVT at the target location -
getOrdinal
public int getOrdinal()Get the local variable ordinal (nth variable of type) -
getIndex
public int getIndex()Get the local variable absolute index -
getNames
Get valid names for consideration -
hasNames
public boolean hasNames()Returns true if names is not empty -
printLVT
public boolean printLVT()True if the injector should print the LVT -
toString
-
toString
-
isImplicit
If the user specifies no values for ordinal, index or names then we are considered to be operating in "implicit mode" where only a single local variable of the specified type is expected to exist.- Parameters:
context- Target context- Returns:
- true if operating in implicit mode
-
findLocal
Find a local variable for the specified context- Parameters:
context- search context- Returns:
- index of local or -1 if not found
-
parse
Parse a local variable discriminator from the supplied annotation- Parameters:
annotation- annotation to parse- Returns:
- discriminator configured using values from the annoation
-