use of org.apache.bcel.generic.ArrayInstruction in project jop by jop-devel.
the class SymbolicPointsTo method printResult.
public void printResult(DFATool program) {
Map<String, String> getFields = new TreeMap<String, String>();
for (InstructionHandle instr : usedRefs.keySet()) {
ContextMap<CallString, BoundedSet<SymbolicAddress>> r = usedRefs.get(instr);
Context c = r.getContext();
MethodInfo method = c.getMethodInfo();
if (method == null) {
throw new AssertionError("Internal Error: No method '" + c.method() + "'");
}
LineNumberTable lines = method.getCode().getLineNumberTable();
int sourceLine = lines.getSourceLine(instr.getPosition());
for (CallString callString : r.keySet()) {
System.out.println(c.method() + ":" + sourceLine + ":" + callString + ": " + instr);
BoundedSet<SymbolicAddress> symAddr = r.get(callString);
String infoStr;
if (instr.getInstruction() instanceof GETFIELD) {
GETFIELD gfInstr = (GETFIELD) instr.getInstruction();
infoStr = String.format("GETFIELD %s %s %s", symAddr.toString(), gfInstr.getFieldName(c.constPool()), gfInstr.getFieldType(c.constPool()));
} else if (instr.getInstruction() instanceof ARRAYLENGTH) {
infoStr = String.format("ARRAYLENGTH %s", symAddr.toString());
} else if (instr.getInstruction() instanceof ArrayInstruction) {
ArrayInstruction aInstr = (ArrayInstruction) instr.getInstruction();
infoStr = String.format("%s %s %s[]", aInstr.getName().toUpperCase(), symAddr.toString(), aInstr.getType(c.constPool()));
} else {
infoStr = String.format("%s %s", instr.getInstruction().getName().toUpperCase(), symAddr.toString());
}
if (infoStr != null) {
String infoKey = String.format("%s:%04d:%s", c.method(), sourceLine, callString);
while (getFields.containsKey(infoKey)) infoKey += "'";
getFields.put(infoKey, infoStr);
}
}
}
for (Entry<String, String> entry : getFields.entrySet()) {
System.out.println(entry.getKey());
System.out.println(" " + entry.getValue());
}
}
use of org.apache.bcel.generic.ArrayInstruction in project jop by jop-devel.
the class ObjectCacheAnalysis method getHandleType.
public static String getHandleType(WCETTool project, ControlFlowGraph cfg, InstructionHandle ih) {
ConstantPoolGen constPool = cfg.getMethodInfo().getConstantPoolGen();
Instruction instr = ih.getInstruction();
if (instr instanceof GETFIELD) {
GETFIELD gf = (GETFIELD) instr;
ReferenceType refty = gf.getReferenceType(constPool);
return refty.toString();
}
if (!ALL_HANDLE_ACCESSES)
return null;
if (instr instanceof PUTFIELD) {
PUTFIELD pf = (PUTFIELD) instr;
ReferenceType refty = pf.getReferenceType(constPool);
return refty.toString();
}
if (instr instanceof ArrayInstruction) {
//ArrayInstruction ainstr = (ArrayInstruction) instr;
return "[]";
}
if (instr instanceof ARRAYLENGTH) {
//ARRAYLENGTH ainstr = (ARRAYLENGTH) instr;
return "[]";
}
if (instr instanceof INVOKEINTERFACE || instr instanceof INVOKEVIRTUAL) {
return "$header";
}
return null;
}
Aggregations