use of com.sun.tools.classfile.ConstantPool in project ceylon-compiler by ceylon.
the class StackMapWriter method print.
void print(verification_type_info entry) {
if (entry == null) {
print("ERROR");
return;
}
switch(entry.tag) {
case -1:
print(((CustomVerificationTypeInfo) entry).text);
break;
case ITEM_Top:
print("top");
break;
case ITEM_Integer:
print("int");
break;
case ITEM_Float:
print("float");
break;
case ITEM_Long:
print("long");
break;
case ITEM_Double:
print("double");
break;
case ITEM_Null:
print("null");
break;
case ITEM_UninitializedThis:
print("uninit_this");
break;
case ITEM_Object:
try {
ConstantPool cp = classWriter.getClassFile().constant_pool;
ConstantPool.CONSTANT_Class_info class_info = cp.getClassInfo(((Object_variable_info) entry).cpool_index);
print(cp.getUTF8Value(class_info.name_index));
} catch (ConstantPoolException e) {
print("??");
}
break;
case ITEM_Uninitialized:
print(((Uninitialized_variable_info) entry).offset);
break;
}
}
use of com.sun.tools.classfile.ConstantPool in project ceylon-compiler by ceylon.
the class StackMapWriter method setStackMap.
void setStackMap(StackMapTable_attribute attr) {
if (attr == null) {
map = null;
return;
}
Method m = classWriter.getMethod();
Descriptor d = m.descriptor;
String[] args;
try {
ConstantPool cp = classWriter.getClassFile().constant_pool;
String argString = d.getParameterTypes(cp);
args = argString.substring(1, argString.length() - 1).split("[, ]+");
} catch (ConstantPoolException e) {
return;
} catch (InvalidDescriptor e) {
return;
}
boolean isStatic = m.access_flags.is(AccessFlags.ACC_STATIC);
verification_type_info[] initialLocals = new verification_type_info[(isStatic ? 0 : 1) + args.length];
if (!isStatic)
initialLocals[0] = new CustomVerificationTypeInfo("this");
for (int i = 0; i < args.length; i++) {
initialLocals[(isStatic ? 0 : 1) + i] = new CustomVerificationTypeInfo(args[i].replace(".", "/"));
}
map = new HashMap<Integer, StackMap>();
StackMapBuilder builder = new StackMapBuilder();
// using -1 as the pc for the initial frame effectively compensates for
// the difference in behavior for the first stack map frame (where the
// pc offset is just offset_delta) compared to subsequent frames (where
// the pc offset is always offset_delta+1).
int pc = -1;
map.put(pc, new StackMap(initialLocals, empty));
for (int i = 0; i < attr.entries.length; i++) pc = attr.entries[i].accept(builder, pc);
}
use of com.sun.tools.classfile.ConstantPool in project ceylon-compiler by ceylon.
the class ClassWriter method writeConstantPool.
protected void writeConstantPool() {
ConstantPool pool = classFile.constant_pool;
int size = pool.size();
out.writeShort(size);
for (CPInfo cpInfo : pool.entries()) constantPoolWriter.write(cpInfo, out);
}
Aggregations