private[this] def readMarker()

in scrooge-adaptive/src/main/scala/com/twitter/scrooge/adapt/AdaptASMPruner.scala [146:191]


  private[this] def readMarker(iter: ListIterator[_], markerType: String): Option[Short] = {
    // Skip first instruction
    // There should be at least 3 instructions, early exit if none
    if (!iter.hasNext) {
      return None
    }

    // This instruction should be loading AdaptTProtocol$MODULE$, if not
    // then this is not a valid marker, early exit
    if (!isAdaptTProtocolModuleLoadInstruction(iter.next())) {
      iter.previous()
      return None
    }

    // Skip second instruction
    // There should be at least 3 instructions, early exit if only one
    if (!iter.hasNext) {
      // Restore to original state before exiting
      iter.previous()
      return None
    }
    iter.next()

    // There should be at least 3 instructions, early exit if only two
    if (!iter.hasNext) {
      // Restore to original state before exiting
      iter.previous()
      iter.previous()
      return None
    }

    iter.next() match {
      case mInsn: MethodInsnNode if mInsn.name == markerType =>
        iter.previous()
        iter.previous()
        val fieldId = readFieldIdFromInstruction(iter.next())
        iter.previous()
        iter.previous()
        Some(fieldId)
      case _ =>
        iter.previous()
        iter.previous()
        iter.previous()
        None
    }
  }