Package org.spongepowered.asm.mixin.injection.struct

## 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
`static ArgOffsets` `DEFAULT` Null offsets
`static java.lang.String` `KEY` Decoration key for this decoration type

### Constructor Summary

Constructors
`ArgOffsets​(int offset, int length)` Create contiguous offsets starting from start and continuing for length

### Method Summary

All Methods Instance Methods Concrete Methods
`org.objectweb.asm.Type[]` `apply​(org.objectweb.asm.Type[] args)` Apply this offset collection to the supplied argument array
`int` `getArgIndex​(int index)` Compute the argument index for the specified new index
`int` `getArgIndex​(int index, boolean mustBeInWindow)` Compute the argument index for the specified new index
`int` `getEndIndex()` Compute the argument index for the end of the window (offset length)
`int` `getLength()` Get the size of the offset window
`int` `getStartIndex()` Compute the argument index for the start of the window (offet 0)
`boolean` `isEmpty()` Get whether this argument offset window is empty
`void` `replace​(ArgOffsets old)` Called when this decoration replaces a previous decoration with the same key
`java.lang.String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### 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

### Constructor Detail

#### ArgOffsets

    public ArgOffsets​(int offset,
                      int length)

Create contiguous offsets starting from start and continuing for length

Parameters:
  `offset` - start index
  `length` - length

### Method Detail

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### replace

    public void replace​(ArgOffsets old)

Description copied from interface: `IChainedDecoration`
Called when this decoration replaces a previous decoration with the same key

Specified by:
  `replace` in interface `IChainedDecoration<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 compute
  `mustBeInWindow` - 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