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