Search in sources :

Example 1 with SubroutineExitInstruction

use of org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineExitInstruction in project kotlin by JetBrains.

the class CFGraphToDotFilePrinter method dumpNodes.

private static void dumpNodes(List<Instruction> instructions, PrintStream out, int[] count, Map<Instruction, String> nodeToName, Set<Instruction> remainedAfterPostProcessInstructions) {
    for (Instruction node : instructions) {
        String name = "n" + count[0]++;
        nodeToName.put(node, name);
        String text = node.toString();
        int newline = text.indexOf("\n");
        if (newline >= 0) {
            text = text.substring(0, newline);
        }
        String shape = "box";
        if (node instanceof ConditionalJumpInstruction || node instanceof UnconditionalJumpInstruction) {
            shape = "diamond";
        } else if (node instanceof NondeterministicJumpInstruction) {
            shape = "Mdiamond";
        } else if (node instanceof MagicInstruction && ((MagicInstruction) node).getKind() == MagicKind.UNSUPPORTED_ELEMENT) {
            shape = "box, fillcolor=red, style=filled";
        } else if (node instanceof LocalFunctionDeclarationInstruction) {
            shape = "Mcircle";
        } else if (node instanceof SubroutineEnterInstruction || node instanceof SubroutineExitInstruction) {
            shape = "roundrect, style=rounded";
        }
        if (!remainedAfterPostProcessInstructions.contains(node)) {
            shape += "box, fillcolor=grey, style=filled";
        }
        out.println(name + "[label=\"" + text + "\", shape=" + shape + "];");
    }
}
Also used : LocalFunctionDeclarationInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.special.LocalFunctionDeclarationInstruction) MagicInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.MagicInstruction) SubroutineExitInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineExitInstruction) SubroutineEnterInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineEnterInstruction) Instruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction) SubroutineSinkInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineSinkInstruction) SubroutineExitInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineExitInstruction) SubroutineEnterInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineEnterInstruction) MagicInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.MagicInstruction) LocalFunctionDeclarationInstruction(org.jetbrains.kotlin.cfg.pseudocode.instructions.special.LocalFunctionDeclarationInstruction)

Aggregations

Instruction (org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction)1 MagicInstruction (org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.MagicInstruction)1 LocalFunctionDeclarationInstruction (org.jetbrains.kotlin.cfg.pseudocode.instructions.special.LocalFunctionDeclarationInstruction)1 SubroutineEnterInstruction (org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineEnterInstruction)1 SubroutineExitInstruction (org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineExitInstruction)1 SubroutineSinkInstruction (org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineSinkInstruction)1