Class ArgOffsets
java.lang.Object
org.spongepowered.asm.mixin.injection.struct.ArgOffsets
- All Implemented Interfaces:
IChainedDecoration<ArgOffsets>
Decoration which stores a linear offset of arguments when a node replacement
results in a call to a method with the same arguments as the original
(replaced) call but offset by some fixed amount. Since ModifyArg and
ModifyArgs always assume the method args are on the top of the stack (which
they must be), this results in locating the original method args as as a
contiguous "window" of arguments somewhere in the middle of the args as they
exist at application time.
Injectors which mutate the arguments of an invocation should apply this decoration to indicate the starting offset and size of the window which contains the original args.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ArgOffsetsNull offsetsstatic final StringDecoration key for this decoration type -
Constructor Summary
ConstructorsConstructorDescriptionArgOffsets(int offset, int length) Create contiguous offsets starting from start and continuing for length -
Method Summary
Modifier and TypeMethodDescriptionorg.objectweb.asm.Type[]apply(org.objectweb.asm.Type[] args) Apply this offset collection to the supplied argument arrayintgetArgIndex(int index) Compute the argument index for the specified new indexintgetArgIndex(int index, boolean mustBeInWindow) Compute the argument index for the specified new indexintCompute the argument index for the end of the window (offset length)intGet the size of the offset windowintCompute the argument index for the start of the window (offet 0)booleanisEmpty()Get whether this argument offset window is emptyvoidreplace(ArgOffsets old) Called when this decoration replaces a previous decoration with the same keytoString()
-
Field Details
-
DEFAULT
Null offsets -
KEY
Decoration key for this decoration type- See Also:
-
-
Constructor Details
-
ArgOffsets
public ArgOffsets(int offset, int length) Create contiguous offsets starting from start and continuing for length- Parameters:
offset- start indexlength- length
-
-
Method Details
-
toString
-
replace
Description copied from interface:IChainedDecorationCalled when this decoration replaces a previous decoration with the same key- Specified by:
replacein interfaceIChainedDecoration<ArgOffsets>- Parameters:
old- The previous decoration
-
getLength
public int getLength()Get the size of the offset window -
isEmpty
public boolean isEmpty()Get whether this argument offset window is empty -
getStartIndex
public int getStartIndex()Compute the argument index for the start of the window (offet 0)- Returns:
- the offset index for the start of the window (inclusive)
-
getEndIndex
public int getEndIndex()Compute the argument index for the end of the window (offset length)- Returns:
- the offset index for the end of the window (inclusive)
-
getArgIndex
public int getArgIndex(int index) Compute the argument index for the specified new index- Parameters:
index- The new index to compute- Returns:
- The original index based on this mapping
-
getArgIndex
public int getArgIndex(int index, boolean mustBeInWindow) Compute the argument index for the specified new index- Parameters:
index- The new index to computemustBeInWindow- Throw an exception if the requested index exceeds the length of the defined window- Returns:
- The original index based on this mapping
-
apply
public org.objectweb.asm.Type[] apply(org.objectweb.asm.Type[] args) Apply this offset collection to the supplied argument array- Parameters:
args- New arguments- Returns:
- Unmapped arguments
-