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 016 switch (value) { 017 case 0: 018 mv.visitInsn(ICONST_0); 019 break; 020 case 1: 021 mv.visitInsn(ICONST_1); 022 break; 023 case 2: 024 mv.visitInsn(ICONST_2); 025 break; 026 case 3: 027 mv.visitInsn(ICONST_3); 028 break; 029 case 4: 030 mv.visitInsn(ICONST_4); 031 break; 032 case 5: 033 mv.visitInsn(ICONST_5); 034 break; 035 default: 036 if (value <= Byte.MAX_VALUE){ 037 mv.visitIntInsn(BIPUSH, value); 038 } else { 039 mv.visitIntInsn(SIPUSH, value); 040 } 041 } 042 } 043}