Examples of PlainTextOutput


Examples of com.strobel.decompiler.PlainTextOutput

        block.addChild(new Comment(" ", CommentType.SingleLine), Roles.COMMENT);
        block.addChild(new Comment(" This method could not be decompiled.", CommentType.SingleLine), Roles.COMMENT);
        block.addChild(new Comment(" ", CommentType.SingleLine), Roles.COMMENT);

        try {
            final PlainTextOutput bytecodeOutput = new PlainTextOutput();
            final DecompilationOptions bytecodeOptions = new DecompilationOptions();

            bytecodeOptions.getSettings().setIncludeLineNumbersInBytecode(false);

            Languages.bytecode().decompileMethod(method, bytecodeOutput, bytecodeOptions);

            final List<String> bytecodeLines = StringUtilities.split(
                bytecodeOutput.toString(),
                true,
                '\r',
                '\n'
            );
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

    private static String formatByteCodeOperand(final Object operand) {
        if (operand == null) {
            return StringUtilities.EMPTY;
        }

        final PlainTextOutput output = new PlainTextOutput();
        DecompilerHelpers.writeOperand(output, operand);
        return output.toString();
    }
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

    public String getText(final JavaFormattingOptions options) {
        if (isNull()) {
            return StringUtilities.EMPTY;
        }

        final ITextOutput output = new PlainTextOutput();
        final JavaOutputVisitor visitor = new JavaOutputVisitor(output, JavaFormattingOptions.createDefault());

        acceptVisitor(visitor, null);

        return output.toString();
    }
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

public abstract class Node {
    public abstract void writeTo(final ITextOutput output);

    @Override
    public String toString() {
        final PlainTextOutput output = new PlainTextOutput();
        writeTo(output);
        return output.toString();
    }
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

                    output.writeAttribute(attribute.getName());
                    output.writeLine(":");
                    output.indent();

                    final PlainTextOutput temp = new PlainTextOutput();

                    DecompilerHelpers.writeMethodSignature(temp, method);
                    DecompilerHelpers.writeMethodSignature(output, method);

                    if (!StringUtilities.equals(temp.toString(), signature)) {
                        output.write(' ');
                        output.writeDelimiter("[");
                        output.write("from metadata: ");
                        output.writeError(signature);
                        output.writeDelimiter("]");
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

        }
    }

    @Override
    public String typeToString(final TypeReference type, final boolean includePackage) {
        final ITextOutput output = new PlainTextOutput();
        DecompilerHelpers.writeType(output, type, includePackage ? NameSyntax.TYPE_NAME : NameSyntax.SHORT_TYPE_NAME);
        return output.toString();
    }
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

        return false;
    }

    @Override
    public final String toString() {
        final PlainTextOutput output = new PlainTextOutput();

        switch (_nodeType) {
            case Normal: {
                output.write("Block #%d", _blockIndex);

                if (_start != null) {
                    output.write(": %d to %d", _start.getOffset(), _end.getEndOffset());
                }

                break;
            }

            case CatchHandler:
            case FinallyHandler: {
                output.write("Block #%d: %s: ", _blockIndex, _nodeType);
                DecompilerHelpers.writeExceptionHandler(output, _exceptionHandler);
                break;
            }

            default: {
                output.write("Block #%d: %s", _blockIndex, _nodeType);
                break;
            }
        }

        output.indent();

        if (!_dominanceFrontier.isEmpty()) {
            output.writeLine();
            output.write("DominanceFrontier: ");

            final int[] blockIndexes = new int[_dominanceFrontier.size()];

            int i = 0;

            for (final ControlFlowNode node : _dominanceFrontier) {
                blockIndexes[i++] = node._blockIndex;
            }

            Arrays.sort(blockIndexes);

            output.write(
                StringUtilities.join(
                    ", ",
                    new Iterable<String>() {
                        @NotNull
                        @Override
                        public Iterator<String> iterator() {
                            return new Iterator<String>() {
                                private int _position = 0;

                                @Override
                                public boolean hasNext() {
                                    return _position < blockIndexes.length;
                                }

                                @Override
                                public String next() {
                                    if (!hasNext()) {
                                        throw new NoSuchElementException();
                                    }
                                    return String.valueOf(blockIndexes[_position++]);
                                }

                                @Override
                                public void remove() {
                                    throw ContractUtils.unreachable();
                                }
                            };
                        }
                    }
                )
            );
        }

        for (final Instruction instruction : getInstructions()) {
            output.writeLine();
            DecompilerHelpers.writeInstruction(output, instruction);
        }

        final Object userData = _userData;

        if (userData != null) {
            output.writeLine();
            output.write(String.valueOf(userData));
        }

        output.unindent();

        return output.toString();
    }
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

        throw new IllegalStateException("No common dominator found!");
    }

    public final void export(final File path) {
        final PlainTextOutput output = new PlainTextOutput();

        output.writeLine("digraph g {");
        output.indent();

        final Set<ControlFlowEdge> edges = new LinkedHashSet<>();

        for (final ControlFlowNode node : _nodes) {
            output.writeLine("\"%s\" [", nodeName(node));
            output.indent();

            output.writeLine(
                "label = \"<f0> %s\"",
                node.toString()
                    .replace("\"", "\\\"")
                    .replace("|", "\\|")
                    .replace("{", "\\{")
                    .replace("}", "\\}")
                    .replace("<", "\\<")
                    .replace(">", "\\>")
            );

            output.writeLine("shape = \"record\"");

            output.unindent();
            output.writeLine("];");

            edges.addAll(node.getIncoming());
            edges.addAll(node.getOutgoing());

            final ControlFlowNode endFinallyNode = node.getEndFinallyNode();

            if (endFinallyNode != null) {
                output.writeLine("\"%s\" [", nodeName(endFinallyNode));
                output.indent();

                output.writeLine(
                    "label = \"<f0> %s\"",
                    endFinallyNode.toString()
                                  .replace("\"", "\\\"")
                                  .replace("|", "\\|")
                                  .replace("{", "\\{")
                                  .replace("}", "\\}")
                                  .replace("<", "\\<")
                                  .replace(">", "\\>")
                );

                output.writeLine("shape = \"record\"");

                output.unindent();
                output.writeLine("];");

                edges.addAll(endFinallyNode.getIncoming());
                edges.addAll(endFinallyNode.getOutgoing());
                edges.add(new ControlFlowEdge(node, endFinallyNode, JumpType.EndFinally));
            }
        }

        for (final ControlFlowEdge edge : edges) {
            final ControlFlowNode from = edge.getSource();
            final ControlFlowNode to = edge.getTarget();

            output.writeLine("\"%s\":f0 -> \"%s\":f0 [", nodeName(from), nodeName(to));
            output.indent();
            output.writeLine("label = \"%s\"", edge.getType());
            output.unindent();
            output.writeLine("];");
        }

        output.unindent();
        output.writeLine("}");

        try (final OutputStreamWriter out = new FileWriter(path)) {
            out.write(output.toString());
        }
        catch (IOException e) {
            throw ExceptionUtilities.asRuntimeException(e);
        }
    }
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

        return copy;
    }

    @Override
    public String toString() {
        final PlainTextOutput output = new PlainTextOutput();
        DecompilerHelpers.writeInstruction(output, this);
        return output.toString();
    }
View Full Code Here

Examples of com.strobel.decompiler.PlainTextOutput

        return _catchType;
    }

    @Override
    public final String toString() {
        final PlainTextOutput output = new PlainTextOutput();
        DecompilerHelpers.writeExceptionHandler(output, this);
        return output.toString();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.