public void newObject(TypeDesc type) {
methodVisitor.visitTypeInsn(Opcodes.NEW, getClassName(type));
}
+
+ public void newObject(String type) {
+ methodVisitor.visitTypeInsn(Opcodes.NEW, type);
+ }
public void newObject(TypeDesc type, int dimensions) {
methodVisitor.visitMultiANewArrayInsn(type.getDescriptor(), dimensions);
public static String getClassName(Class<?> clazz) {
return clazz.getName().replace('.', '/');
}
+
+ public void switch_(int[] values, Label[] labels, Label defaultLabel) {
+ int lo = values[0];
+ int hi = values[values.length-1];
+ long table_space_cost = 4 + ((long) hi - lo + 1); // words
+ long table_time_cost = 3; // comparisons
+ long lookup_space_cost = 3 + 2 * (long) values.length;
+ long lookup_time_cost = values.length;
+ if(values.length > 0 &&
+ table_space_cost + 3 * table_time_cost <=
+ lookup_space_cost + 3 * lookup_time_cost) {
+ Label[] table = new Label[hi - lo + 1];
+ for(int i=0,j=0;i<table.length;++i) {
+ int id = lo+i;
+ if(values[j] == id) {
+ table[i] = labels[j];
+ ++j;
+ }
+ else
+ table[i] = defaultLabel;
+ }
+ methodVisitor.visitTableSwitchInsn(lo, hi, defaultLabel, table);
+ }
+ else
+ methodVisitor.visitLookupSwitchInsn(defaultLabel, values, labels);
+ }
}