001package io.ebean.enhance.common;
002
003import io.ebean.enhance.asm.MethodVisitor;
004import io.ebean.enhance.asm.Opcodes;
005
006public final class VisitUtil implements Opcodes {
007
008  /**
009   * Append the interfaceType to the existing class signature.
010   */
011  public static String signatureAppend(String signature, String interfaceType) {
012    return signature == null ? null : signature + 'L' + interfaceType + ';';
013  }
014
015  /**
016  * Helper method for visiting an int value.
017  * <p>
018  * This can use special constant values for int values from 0 to 5.
019  * </p>
020  */
021  public static void visitIntInsn(MethodVisitor mv, int value) {
022    switch (value) {
023      case 0:
024        mv.visitInsn(ICONST_0);
025        break;
026      case 1:
027        mv.visitInsn(ICONST_1);
028        break;
029      case 2:
030        mv.visitInsn(ICONST_2);
031        break;
032      case 3:
033        mv.visitInsn(ICONST_3);
034        break;
035      case 4:
036        mv.visitInsn(ICONST_4);
037        break;
038      case 5:
039        mv.visitInsn(ICONST_5);
040        break;
041      default:
042        if (value <= Byte.MAX_VALUE){
043          mv.visitIntInsn(BIPUSH, value);
044        } else {
045          mv.visitIntInsn(SIPUSH, value);
046        }
047    }
048  }
049}