Enum MethodVariableAccess

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<MethodVariableAccess>

    public enum MethodVariableAccess
    extends java.lang.Enum<MethodVariableAccess>
    A stack assignment that loads a method variable from a given index of the local variable array.
    • Field Detail

      • loadOpcode

        private final int loadOpcode
        The opcode for loading this variable type.
      • storeOpcode

        private final int storeOpcode
        The opcode for storing a local variable type.
      • size

        private final StackSize size
        The size of the local variable on the JVM stack.
    • Constructor Detail

      • MethodVariableAccess

        private MethodVariableAccess​(int loadOpcode,
                                     int storeOpcode,
                                     StackSize stackSize)
        Creates a new method variable access for a given JVM type.
        Parameters:
        loadOpcode - The opcode for loading this variable type.
        storeOpcode - The opcode for storing this variable type.
        stackSize - The size of the JVM type.
    • Method Detail

      • values

        public static MethodVariableAccess[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MethodVariableAccess c : MethodVariableAccess.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MethodVariableAccess valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • of

        public static MethodVariableAccess of​(TypeDefinition typeDefinition)
        Locates the correct accessor for a variable of a given type.
        Parameters:
        typeDefinition - The type of the variable to be loaded.
        Returns:
        An accessor for the given type.
      • allArgumentsOf

        public static MethodVariableAccess.MethodLoading allArgumentsOf​(MethodDescription methodDescription)
        Loads all arguments of the provided method onto the operand stack.
        Parameters:
        methodDescription - The method for which all parameters are to be loaded onto the operand stack.
        Returns:
        A stack manipulation that loads all parameters of the provided method onto the operand stack.
      • loadThis

        public static StackManipulation loadThis()
        Loads a reference to the this reference what is only meaningful for a non-static method.
        Returns:
        A stack manipulation loading the this reference.
      • loadFrom

        public StackManipulation loadFrom​(int offset)
        Creates a stack assignment for a reading given offset of the local variable array.
        Parameters:
        offset - The offset of the variable where double and long types count two slots.
        Returns:
        A stack manipulation representing the variable read.
      • storeAt

        public StackManipulation storeAt​(int offset)
        Creates a stack assignment for writing to a given offset of the local variable array.
        Parameters:
        offset - The offset of the variable where double and long types count two slots.
        Returns:
        A stack manipulation representing the variable write.
      • increment

        public StackManipulation increment​(int offset,
                                           int value)
        Creates a stack assignment for incrementing the given offset of the local variable array.
        Parameters:
        offset - The offset of the variable where double and long types count two slots.
        value - The incremented value.
        Returns:
        A stack manipulation representing the variable write.
      • load

        public static StackManipulation load​(ParameterDescription parameterDescription)
        Loads a parameter's value onto the operand stack.
        Parameters:
        parameterDescription - The parameter which to load onto the operand stack.
        Returns:
        A stack manipulation loading a parameter onto the operand stack.
      • store

        public static StackManipulation store​(ParameterDescription parameterDescription)
        Stores the top operand stack value at the supplied parameter.
        Parameters:
        parameterDescription - The parameter which to store a value for.
        Returns:
        A stack manipulation storing the top operand stack value at this parameter.
      • increment

        public static StackManipulation increment​(ParameterDescription parameterDescription,
                                                  int value)
        Increments the value of the supplied parameter.
        Parameters:
        parameterDescription - The parameter which to increment.
        value - The value to increment with.
        Returns:
        A stack manipulation incrementing the supplied parameter.