Search in sources :

Example 1 with ValueMapping

use of com.jopdesign.dfa.analyses.ValueMapping in project jop by jop-devel.

the class DFATool method dumpDFA.

public String dumpDFA(MethodInfo method) {
    if (getLoopBounds() == null)
        return "n/a";
    if (method.isAbstract()) {
        return "n/a";
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream os = new PrintStream(baos);
    Map<InstructionHandle, ContextMap<CallString, Pair<ValueMapping, ValueMapping>>> results = getLoopBounds().getResult();
    if (results == null)
        return "n/a";
    AnalysisResultSerialization<Pair<ValueMapping, ValueMapping>> printer = new AnalysisResultSerialization<Pair<ValueMapping, ValueMapping>>();
    for (Entry<InstructionHandle, ContextMap<CallString, Pair<ValueMapping, ValueMapping>>> ihEntry : results.entrySet()) {
        for (Entry<CallString, Pair<ValueMapping, ValueMapping>> csEntry : ihEntry.getValue().entrySet()) {
            if (ihEntry.getValue().getContext().getMethodInfo().equals(method)) {
                printer.addResult(method, ihEntry.getKey().getPosition(), csEntry.getKey(), csEntry.getValue());
            }
        }
    }
    printer.dump(os);
    try {
        return baos.toString("UTF-8");
    } catch (UnsupportedEncodingException e) {
        return baos.toString();
    }
}
Also used : PrintStream(java.io.PrintStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) InstructionHandle(org.apache.bcel.generic.InstructionHandle) ContextMap(com.jopdesign.dfa.framework.ContextMap) ValueMapping(com.jopdesign.dfa.analyses.ValueMapping) CallString(com.jopdesign.common.code.CallString) AnalysisResultSerialization(com.jopdesign.dfa.framework.AnalysisResultSerialization) Pair(com.jopdesign.common.graphutils.Pair)

Aggregations

CallString (com.jopdesign.common.code.CallString)1 Pair (com.jopdesign.common.graphutils.Pair)1 ValueMapping (com.jopdesign.dfa.analyses.ValueMapping)1 AnalysisResultSerialization (com.jopdesign.dfa.framework.AnalysisResultSerialization)1 ContextMap (com.jopdesign.dfa.framework.ContextMap)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InstructionHandle (org.apache.bcel.generic.InstructionHandle)1