GithubHelp home page GithubHelp logo

Support for custom output about cfr HOT 11 OPEN

Cubxity avatar Cubxity commented on August 16, 2024 4
Support for custom output

from cfr.

Comments (11)

Cubxity avatar Cubxity commented on August 16, 2024 1

Alright, I'm making a fork for my attempt at this https://github.com/bytespy/cfr

from cfr.

leibnitz27 avatar leibnitz27 commented on August 16, 2024 1

I ended up going for a 'token-stream-with-semantic-info' rather than an explicit interface. I don't want to expose the internal interface, and this fits better with my aim of keeping the external API compatible in both directions.

There's an example in https://github.com/leibnitz27/cfr_client/blob/master/src/org/benf/cfr_client_example/WithTokenSink.java

from cfr.

Col-E avatar Col-E commented on August 16, 2024

This would be pretty useful. I've been using JavaParser's SymbolSolver for this so far. If this isn't in-scope you can always try that out.

from cfr.

Cubxity avatar Cubxity commented on August 16, 2024

@Col-E it is possible for the classes to have some weird characters that could potentially affect the symbol solver like { for example

from cfr.

Col-E avatar Col-E commented on August 16, 2024

As long as the AST is built it should work. I've not tested on obfuscated code if that's what you're asking.

from cfr.

leibnitz27 avatar leibnitz27 commented on August 16, 2024

FWIW - the current internal api is https://github.com/leibnitz27/cfr/blob/master/src/org/benf/cfr/reader/util/output/Dumper.java

which is more of a literal string stream than ITextOutput. It wouldn't be too tricky to convert usages to a similar api. (note that there's some state which is used to handle how types are viewed etc).

However .....

I have a sneaky (ENTIRELY UNJUSTIFIED) feeling that the next logical step is basically to export a parse tree, rather than something like a string stream.

The issue there (yak shaving time!) is that I don't want to use standard JDK parse tree types, because I am very attached to 'any version of java' with forwards compatibility. And I don't want to export the internal AST types, because they contain a great deal of hackery that isn't locked down.

I'm tempted to bypass the intermediate stage.

from cfr.

Cubxity avatar Cubxity commented on August 16, 2024

@leibnitz27 Would it be possible for you to add an option to set a custom dumper factory in CfrDriverImpl as seen here?
image

from cfr.

Cubxity avatar Cubxity commented on August 16, 2024

@leibnitz27 could you add methods like "writeComment", "writeKeyword", "writeDelimiter", etc. like procyon's ITextOutput? This would be very useful for syntax highlighting

from cfr.

Cubxity avatar Cubxity commented on August 16, 2024

@leibnitz27 also would it be possible to make objects for identifier like method, fields, variables instead of string?
image

from cfr.

leibnitz27 avatar leibnitz27 commented on August 16, 2024

Cool - please bear in mind a few small things:

I massively prefer not to expose internal APIs, because I really appreciate the freedom to screw with them (you might have noticed). So either implement an externally visible API in dumper, or expose to the outside world via an adaptor please.

Also note that the dumper (effctively) carries a type registration burden, which really doesn't want to be exposed to the outside world.

from cfr.

NKU915 avatar NKU915 commented on August 16, 2024

How can dump the original bytecode of method code attribute when CFR failed to decompile? As Procyon decompiler does(pls refer the attachement), thanks.
Jietu20191104-121139

from cfr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.