Class ArgOffsets
- java.lang.Object
-
- org.spongepowered.asm.mixin.injection.struct.ArgOffsets
-
- All Implemented Interfaces:
IChainedDecoration<ArgOffsets>
public class ArgOffsets extends java.lang.Object implements 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
Fields Modifier and Type Field Description static ArgOffsetsDEFAULTNull offsetsstatic java.lang.StringKEYDecoration key for this decoration type
-
Constructor Summary
Constructors Constructor Description ArgOffsets(int offset, int length)Create contiguous offsets starting from start and continuing for length
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.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 indexintgetEndIndex()Compute the argument index for the end of the window (offset length)intgetLength()Get the size of the offset windowintgetStartIndex()Compute 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 keyjava.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT
public static ArgOffsets DEFAULT
Null offsets
-
KEY
public static final java.lang.String KEY
Decoration key for this decoration type- See Also:
- Constant Field Values
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
replace
public void replace(ArgOffsets old)
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
-
-