private[this] def readFieldIdFromInstruction()

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


  private[this] def readFieldIdFromInstruction(insn: Any): Short =
    insn match {
      case i: InsnNode =>
        i.getOpcode match {
          case Opcodes.ICONST_0 => 0
          case Opcodes.ICONST_1 => 1
          case Opcodes.ICONST_2 => 2
          case Opcodes.ICONST_3 => 3
          case Opcodes.ICONST_4 => 4
          case Opcodes.ICONST_5 => 5
          case Opcodes.ICONST_M1 => -1
          case _ =>
            throw new IllegalStateException(
              s"Unexpected opcode ${i.getOpcode} while trying to read fieldId"
            )
        }
      case i: IntInsnNode =>
        i.getOpcode match {
          case Opcodes.BIPUSH => i.operand.toShort
          case Opcodes.SIPUSH => i.operand.toShort
        }
      case _ =>
        throw new IllegalStateException(
          s"Unexpected instruction $insn while trying to read fieldId"
        )
    }