Class CodeAttr

java.lang.Object
org.openjdk.asmtools.jasm.AttrData
org.openjdk.asmtools.jasm.CodeAttr
All Implemented Interfaces:
ConstantPoolDataVisitor, DataWriter

class CodeAttr extends AttrData
4.7.3. The Code Attribute

Code_attribute { u2 attribute_name_index; u4 attribute_length; u2 max_stack; u2 max_locals; u4 code_length; u1 code[code_length]; u2 exception_table_length; { u2 start_pc; u2 end_pc; u2 handler_pc; u2 catch_type; } exception_table[exception_table_length]; u2 attributes_count; attribute_info attributes[attributes_count]; }

  • Field Details

  • Constructor Details

  • Method Details

    • endCode

      void endCode()
    • addAnnotations

      public void addAnnotations(ArrayList<AnnotationData> list)
    • fillLineTable

      public void fillLineTable(List<LineNumberData> list)
    • fillLocalVariableTable

      public void fillLocalVariableTable(boolean isTypeTable, List<LocalVariableData> list)
      Fills either localVariableTable or localVariableTypeTable according to the boolean parameter isTypeTable
      Parameters:
      isTypeTable - defines which localVariableTypeTable or localVariableTable is filled
      list - list of local_variable_table[i] or local_variable_type_table[i] entries
    • fillStackMapTable

      public void fillStackMapTable(List<StackMapData> list)
    • trapDecl

      CodeAttr.RangePC trapDecl(long pos, String name)
    • beginTrap

      void beginTrap(long pos, String name)
    • endTrap

      void endTrap(long pos, String name)
    • trapHandler

      void trapHandler(long pos, String name, Indexer type)
    • checkTraps

      void checkTraps()
    • labelDecl

      CodeAttr.Label labelDecl(String name)
    • LabelDef

      public CodeAttr.Label LabelDef(long pos, String name)
    • LabelRef

      public CodeAttr.Label LabelRef(String name)
    • checkLabels

      void checkLabels()
    • LocVarDataDef

      public void LocVarDataDef(OpcodeTables.Opcode opcode, long position, int index, ConstCell<?> nameCell, ConstCell<?> descriptorCell)
      Constructs the local variable nameCell:descriptorCell assigned to the slot index.
      Parameters:
      opcode - var or type opcode that defines type of filled table -LocalVariableTypeTable or LocalVariableTable
      position - scanners' position to navigate where a syntax error happened if any
      index - a valid index into the local variable array of the current frame
      nameCell - valid unqualified name denoting a local variable
      descriptorCell - a field descriptor which encodes a type of local variable in the source program
    • LocVarDataEnd

      public void LocVarDataEnd(OpcodeTables.Opcode opcode, short slot, long position)
      Marks the end of Local Variable (Type) presented in the form endVar index: locVarSlots[slot] = VACANT and sets the Length of the Local Var
      Parameters:
      position - the position of the scanner
      slot - The value of the index item is a valid index into the local variable array of the current frame.
    • checkLocVars

      void checkLocVars(OpcodeTables.Opcode opcode)
    • getStackMapTable

      public StackMapData getStackMapTable()
    • getNextStackMapTable

      public StackMapData getNextStackMapTable()
    • isTypeCheckingVerifier

      public boolean isTypeCheckingVerifier()
    • addInstr

      void addInstr(long mnenoc_pos, OpcodeTables.Opcode opcode, Indexer arg, Object arg2)
    • getPreviousStackMapEntry

      private StackMapData getPreviousStackMapEntry()
    • attrLength

      public int attrLength()
      Overrides:
      attrLength in class AttrData
    • write

      public void write(CheckedDataOutputStream out) throws IOException, Parser.CompilerError
      Specified by:
      write in interface DataWriter
      Overrides:
      write in class AttrData
      Throws:
      IOException
      Parser.CompilerError
    • isEmpty

      public boolean isEmpty()
      Checks if the code attribute is empty, i.e., it contains no instructions.
      Returns:
      true if the code attribute is empty, false otherwise