Package com.strobel.decompiler

Examples of com.strobel.decompiler.PlainTextOutput


        return result;
    }

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


                  decompilationOptions.setSettings(settings);
                  decompilationOptions
                      .setFullDecompilation(true);
                  settings.getLanguage().decompileType(
                      resolvedType,
                      new PlainTextOutput(stringwriter),
                      decompilationOptions);
                  String decompiledSource = stringwriter
                      .toString().toLowerCase();
                  if (decompiledSource.contains(textField
                      .getText().toLowerCase())) {
View Full Code Here

      if (type == null || ((resolvedType = type.resolve()) == null)) {
        throw new Exception("Unable to resolve type.");
      }
      StringWriter stringwriter = new StringWriter();
      settings.getLanguage().decompileType(resolvedType,
          new PlainTextOutput(stringwriter), decompilationOptions);
      return stringwriter.toString();
    }
  }
View Full Code Here

          if ((type == null) || ((resolvedType = type.resolve()) == null)) {
            return;
          }
          StringWriter stringwriter = new StringWriter();
          settings.getLanguage().decompileType(resolvedType,
              new PlainTextOutput(stringwriter), decompilationOptions);
          String decompiledSource = stringwriter.toString();
          OpenFile open = new OpenFile(internalName, "*/" + internalName, decompiledSource, theme);
          JTabbedPane pane = new JTabbedPane();
          pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
          pane.addTab("title", open.scrollPane);
View Full Code Here

              if ((type == null) || ((resolvedType = type.resolve()) == null)) {
                throw new Exception("Unable to resolve type.");
              }
              Writer writer = new OutputStreamWriter(out);
              settings.getLanguage().decompileType(resolvedType,
                  new PlainTextOutput(writer), decompilationOptions);
              writer.flush();
            } finally {
              out.closeEntry();
            }
          }
View Full Code Here

    if (type == null || ((resolvedType = type.resolve()) == null)) {
      throw new Exception("Unable to resolve type.");
    }
    StringWriter stringwriter = new StringWriter();
    settings.getLanguage().decompileType(resolvedType,
        new PlainTextOutput(stringwriter), decompilationOptions);
    String decompiledSource = stringwriter.toString();

    try (FileWriter fw = new FileWriter(outFile);
        BufferedWriter bw = new BufferedWriter(fw);) {
      bw.write(decompiledSource);
View Full Code Here

        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 = \"%s\\l\"",
                escapeGraphViz(node.toString())
            );

            output.writeLine(", shape = \"box\"");

            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 = \"%s\"",
                    escapeGraphViz(endFinallyNode.toString())
                );

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

                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\" -> \"%s\" [", nodeName(from), nodeName(to));
            output.indent();

            switch (edge.getType()) {
                case Normal:
                    break;

                case LeaveTry:
                    output.writeLine("color = \"blue\"");
                    break;

                case EndFinally:
                    output.writeLine("color = \"red\"");
                    break;

                case JumpToExceptionHandler:
                    output.writeLine("color = \"gray\"");
                    break;

                default:
                    output.writeLine("label = \"%s\"", edge.getType());
                    break;
            }

            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

        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

        return copy;
    }

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

        return _catchType;
    }

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

TOP

Related Classes of com.strobel.decompiler.PlainTextOutput

Copyright © 2018 www.massapicom. 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.