1 package alt.jiapi.reflect; 2 3 import alt.jiapi.file.ConstantPool; 4 import alt.jiapi.file.Field; 5 6 11 class ConstantPoolHelper { 12 static short addMethodReference(ConstantPool cp, String className, 13 String methodName, Signature signature) { 14 ConstantPool.ClassInfo ci = cp.addClassInfo(className); 16 17 ConstantPool.MethodRefInfo mri = 19 cp.addMethodRefInfo(ci, methodName, signature.getDescriptor()); 20 21 return mri.getEntryIndex(); 22 } 23 24 25 static short addReference(ConstantPool cp, JiapiMethod jm) { 26 return addMethodReference(cp, jm.getDeclaringClass().getName(), 27 jm.getName(), jm.getSignature()); 28 } 29 30 31 32 static short addFieldReference(ConstantPool cp, String className, 33 String fieldName, String descriptor) { 34 ConstantPool.ClassInfo ci = cp.addClassInfo(className); 36 37 ConstantPool.FieldRefInfo fri = 39 cp.addFieldRefInfo(ci, fieldName, descriptor); 40 41 return fri.getEntryIndex(); 42 } 43 44 45 static short addReference(ConstantPool cp, JiapiField jf) { 46 return addFieldReference(cp, jf.getDeclaringClass().getName(), 47 jf.getName(), jf.getDescriptor()); 48 } 49 } 50 | Popular Tags |