Interface Opcode

All Known Implementing Classes:
AbstractControlFlowOpcode, AbstractOpcode, BeforeWithOpcode, BinaryDunderOpcode, BuildConstantKeyMapOpcode, BuildListOpcode, BuildMapOpcode, BuildSetOpcode, BuildSliceOpcode, BuildStringOpcode, BuildTupleOpcode, CallFunctionKeywordOpcode, CallFunctionOpcode, CallFunctionUnpackOpcode, CallMethodOpcode, CallOpcode, CheckExcMatchOpcode, CleanupThrowOpcode, CollectionAddAllOpcode, CollectionAddOpcode, CompareOpcode, ContainsOpcode, CopyOpcode, DeleteAttrOpcode, DeleteDerefOpcode, DeleteFastOpcode, DeleteGlobalOpcode, DeleteItemOpcode, DupOpcode, DupTwoOpcode, ForIterOpcode, FormatValueOpcode, GeneratorStartOpcode, GetIterOpcode, GetSliceOpcode, GetYieldFromIterOpcode, ImportFromOpcode, ImportNameOpcode, IsOpcode, JumpAbsoluteOpcode, JumpIfFalseOrPopOpcode, JumpIfNotExcMatchOpcode, JumpIfTrueOrPopOpcode, ListToTupleOpcode, LoadAssertionErrorOpcode, LoadAttrOpcode, LoadClosureOpcode, LoadConstantOpcode, LoadDerefOpcode, LoadFastAndClearOpcode, LoadFastOpcode, LoadGlobalOpcode, LoadMethodOpcode, LoadSuperAttrOpcode, MakeFunctionOpcode, MapMergeOpcode, MapPutAllOpcode, MapPutOpcode, NopOpcode, NotOpcode, OpcodeWithoutSource, PopBlockOpcode, PopExceptOpcode, PopJumpIfFalseOpcode, PopJumpIfIsNoneOpcode, PopJumpIfIsNotNoneOpcode, PopJumpIfTrueOpcode, PopOpcode, PrintExprOpcode, PushExcInfoOpcode, PushNullOpcode, RaiseVarargsOpcode, ReraiseOpcode, ResumeOpcode, ReturnConstantValueOpcode, ReturnGeneratorOpcode, ReturnValueOpcode, RotateFourOpcode, RotateThreeOpcode, RotateTwoOpcode, SelfOpcodeWithoutSource, SendOpcode, SetCallKeywordNameTupleOpcode, SetItemOpcode, SetupFinallyOpcode, SetupWithOpcode, StopIteratorErrorOpcode, StoreAttrOpcode, StoreDerefOpcode, StoreFastOpcode, StoreGlobalOpcode, StoreSliceOpcode, SwapOpcode, UniDunerOpcode, UnpackSequenceOpcode, UnpackSequenceWithTailOpcode, WithExceptStartOpcode, YieldFromOpcode, YieldValueOpcode

public interface Opcode
  • Method Details

    • getBytecodeIndex

      int getBytecodeIndex()
      Return the bytecode index of the instruction, which can be used to identify the instruction as the target of a jump.
      Returns:
      The bytecode index of the instruction, which is defined as the number of instructions before it in the instruction listing.
    • getPossibleNextBytecodeIndexList

      default List<Integer> getPossibleNextBytecodeIndexList()
      Return the possible next bytecode index after this instruction is executed. The default simply return [getBytecodeIndex() + 1], but is typically overwritten in jump instructions.
      Returns:
      the possible next bytecode index after this instruction is executed
    • getStackMetadataAfterInstructionForBranches

      List<StackMetadata> getStackMetadataAfterInstructionForBranches(FunctionMetadata functionMetadata, StackMetadata stackMetadata)
      Return a list of StackMetadata corresponding to each branch returned by getPossibleNextBytecodeIndexList().
      Parameters:
      functionMetadata - Metadata about the function being compiled.
      stackMetadata - the StackMetadata just before this instruction is executed.
      Returns:
      a new List, the same size as getPossibleNextBytecodeIndexList(), containing the StackMetadata after this instruction is executed for the given branch in getPossibleNextBytecodeIndexList().
    • implement

      void implement(FunctionMetadata functionMetadata, StackMetadata stackMetadata)
      Implements the opcode.
      Parameters:
      functionMetadata - Metadata about the function being compiled.
      stackMetadata - Metadata about the state of the stack when this instruction is executed.
    • isJumpTarget

      boolean isJumpTarget()
      Returns:
      true if this opcode the target of a jump
    • isForcedJump

      default boolean isForcedJump()
      Returns:
      true if this opcode is a forced jump (i.e. goto)
    • lookupOpcodeForInstruction

      static Opcode lookupOpcodeForInstruction(PythonBytecodeInstruction instruction, PythonVersion pythonVersion)