use of org.apache.bcel.generic.ObjectType in project jop by jop-devel.
the class ObjectCacheAnalysis method getFieldIndex.
/**
* @return the index of the field accessed by the instruction, or 0 if the instruction
* does not access a field
*/
private static int getFieldIndex(WCETTool p, ControlFlowGraph cfg, InstructionHandle ih) {
ConstantPoolGen constPool = cfg.getMethodInfo().getConstantPoolGen();
Instruction instr = ih.getInstruction();
if (instr instanceof FieldInstruction) {
FieldInstruction fieldInstr = (FieldInstruction) instr;
ReferenceType refType = fieldInstr.getReferenceType(constPool);
if (!(refType instanceof ObjectType)) {
throw new RuntimeException("getFieldIndex(): Unsupported object kind: " + refType.getClass());
}
ObjectType objType = (ObjectType) refType;
String klassName = objType.getClassName();
String fieldName = fieldInstr.getFieldName(constPool);
String fieldSig = fieldInstr.getSignature(constPool);
return p.getLinkerInfo().getFieldIndex(klassName, fieldName + fieldSig);
} else {
return 0;
}
}
Aggregations