Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do/while loop includes an instruction before the loop #25

Open
AdamMil opened this issue Feb 3, 2019 · 1 comment
Open

do/while loop includes an instruction before the loop #25

AdamMil opened this issue Feb 3, 2019 · 1 comment

Comments

@AdamMil
Copy link

@AdamMil AdamMil commented Feb 3, 2019

Compile this code:

i = 1
do j = 0 while (j)

Then decompile it with NutCracker. The result is:

do
{
        this.i = 1;
        this.j = 0;
}
while (this.j);

In general, one operation before a do/while loop is included in the loop. I believe the reason is that the beginning of the loop is calculated incorrectly. In PreprocessDoWhileInfo there's this line:

int beginPos = endPos + curInst.arg1;

I think it should be replaced with:

int beginPos = endPos + 1 + curInst.arg1;
@pabloko
Copy link

@pabloko pabloko commented Sep 24, 2019

a real mvp shares this fix! thanks @AdamMil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants