Interface CompilableIndexAccessor

All Superinterfaces:
IndexAccessor, Opcodes, TargetedAccessor
All Known Implementing Classes:
ReflectiveIndexAccessor

public interface CompilableIndexAccessor extends IndexAccessor, Opcodes
A compilable IndexAccessor is able to generate bytecode that represents the operation for reading the index, facilitating compilation to bytecode of expressions that use the accessor.
Since:
6.2
Author:
Sam Brannen
  • Method Details

    • isCompilable

      boolean isCompilable()
      Determine if this IndexAccessor is currently suitable for compilation.

      May only be known once the index has been read.

      See Also:
    • getIndexedValueType

      Class<?> getIndexedValueType()
      Get the type of the indexed value.

      For example, given the expression book.authors[0], the indexed value type represents the result of authors[0] which may be an Author object, a String representing the author's name, etc.

      May only be known once the index has been read.

      See Also:
    • generateCode

      void generateCode(SpelNode indexNode, MethodVisitor methodVisitor, CodeFlow codeFlow)
      Generate bytecode that performs the operation for reading the index.

      Bytecode should be generated into the supplied MethodVisitor using context information from the CodeFlow where necessary.

      The supplied indexNode should be used to generate the appropriate bytecode to load the index onto the stack. For example, given the expression book.authors[0], invoking codeFlow.generateCodeForArgument(methodVisitor, indexNode, int.class) will ensure that the index (0) is available on the stack as a primitive int.

      Will only be invoked if isCompilable() returns true.

      Parameters:
      indexNode - the SpelNode that represents the index being accessed
      methodVisitor - the ASM MethodVisitor into which code should be generated
      codeFlow - the current state of the expression compiler