Class CodeOffsetAdapter

java.lang.Object
org.objectweb.asm.ClassVisitor
org.checkerframework.afu.scenelib.io.classfile.CodeOffsetAdapter
Direct Known Subclasses:
ClassAnnotationSceneReader, ClassAnnotationSceneWriter

public class CodeOffsetAdapter extends org.objectweb.asm.ClassVisitor
Tracks offset within a method's Code attribute as its instructions are visited. ASM really should expose this information but doesn't. Class implementation simply does the same arithmetic ASM does under the hood, staying synchronized with the ClassReader.

UNDONE: Why both CodeOffsetAdapter and MethodCodeOffsetAdapter?

  • Field Summary

    Fields inherited from class org.objectweb.asm.ClassVisitor

    api, cv
  • Constructor Summary

    Constructors
    Constructor
    Description
    CodeOffsetAdapter(int api, org.objectweb.asm.ClassReader classReader)
    Constructs a new CodeOffsetAdapter.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Fetch bytecode offset.
    int
    Fetch offset.
    int
    Fetch previousOffset.
    org.objectweb.asm.MethodVisitor
    visitMethod(int access, String name, String descriptor, String signature, String[] exceptions)
     

    Methods inherited from class org.objectweb.asm.ClassVisitor

    getDelegate, visit, visitAnnotation, visitAttribute, visitEnd, visitField, visitInnerClass, visitModule, visitNestHost, visitNestMember, visitOuterClass, visitPermittedSubclass, visitRecordComponent, visitSource, visitTypeAnnotation

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CodeOffsetAdapter

      public CodeOffsetAdapter(int api, org.objectweb.asm.ClassReader classReader)
      Constructs a new CodeOffsetAdapter. For some reason, it is necessary to use ClassWriter to ensure that all labels are visited.
      Parameters:
      api - the ASM API version to use
      classReader - the ClassReader for the class
  • Method Details

    • visitMethod

      public org.objectweb.asm.MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions)
      Overrides:
      visitMethod in class org.objectweb.asm.ClassVisitor
    • getPreviousCodeOffset

      public int getPreviousCodeOffset()
      Fetch previousOffset.
      Returns:
      previousOffset
    • getMethodCodeOffset

      public int getMethodCodeOffset()
      Fetch offset.
      Returns:
      offset
    • getBytecodeOffset

      public int getBytecodeOffset()
      Fetch bytecode offset.
      Returns:
      bytecode offset