GithubHelp home page GithubHelp logo

Comments (6)

lab313ru avatar lab313ru commented on August 16, 2024 1

It would be great to comment it or even don't show any such info.
It doesn't give you any interesting info, but in case of trying to compile it will give you an error.

from cfr.

leibnitz27 avatar leibnitz27 commented on August 16, 2024

Thanks for checking the copyright! ;)

I don't think this is a bug, or even bad behaviour - the issue is the explicit pops (well, pop2) in the byte code - compute an expression, and then discard it.

It's very deliberately discarded, and assigning it to an intermediate value is a bit dishonest.

Also, though, throwing away the calculation would be dishonest too. (very much so if it was side effecting, or could throw an exception, even so with the above because, well, it IS being calculated).

To be honest, I think assigning it to a local is bad - that's not what the JVM is doing, and if possible, a decompiler should be honest!

I guess it's possible to add a comment /* discarded value */, but that sort of thing (ignoring return values) happens all the time.

from cfr.

leibnitz27 avatar leibnitz27 commented on August 16, 2024

Oh, that's a really good point. Whoops! Guess I'll have to consume (or find a cleaner way of not-a-statement)ing them.

Thanks.

from cfr.

lab313ru avatar lab313ru commented on August 16, 2024

As for example, Krakatau output:

public static String fib(String s) {
    int i = s.length();
    char[] a = new char[i];
    int i0 = i - 1;
    while(true) {
        if (i0 >= 0) {
            int i1 = s.charAt(i0);
            int i2 = i0 + -1;
            int i3 = (char)(i1 ^ 58);
            a[i0] = (char)i3;
            if (i2 >= 0) {
                i0 = i2 + -1;
                int i4 = s.charAt(i2);
                int i5 = (char)(i4 ^ 97);
                a[i2] = (char)i5;
                continue;
            }
        }
        return new String(a);
    }
}

Looks great.:) Could you make it the same?) I mean calculating values.

from cfr.

leibnitz27 avatar leibnitz27 commented on August 16, 2024

Eh. Here, I'm much less convinced. This hides the fact that the bytecode has some operations in it.
I definitely don't think it's the job of the decompiler to do constant folding - if the compiler hasn't done it, I want to know that!

Consider the difference between

1 | 2 | 4 | 8 | x

and

x | 8 | 4 | 2 | 1

http://www.benf.org/other/cfr/constant-folding.html

from cfr.

lab313ru avatar lab313ru commented on August 16, 2024

Thanks:) Ok, you're right.

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.