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

fix: div instruction parsing and add test with mathlib #16

Merged
merged 5 commits into from
Jul 21, 2024

Conversation

Gusarich
Copy link
Member

@Gusarich Gusarich commented Jul 20, 2024

Closes #15 and also closes tact-lang/tact#396

@@ -1835,3 +1835,129 @@ exports[`decompileAll should decompile wallet v4 1`] = `
}>
}END>c"
`;

exports[`decompileAll should decompile mathlib.fc 1`] = `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not look like this covers the whole mathlib.fc: https://github.com/ton-blockchain/ton/blob/5c392e0f2d946877bb79a09ed35068f7b0bd333a/crypto/smartcont/mathlib.fc, which is almost a thousand lines of code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's right, it doesn't. I guess it might be enough in context of the original issue, but I can make it to include all of the functions by calling them in main().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, let's include the whole thing into the test

Copy link
Member Author

@Gusarich Gusarich Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried compiling the whole thing with func optimizations turned off so that all of the functions are included into result. Test failed but not because of ton-opcode but because of @ton/core boc deserialization:

Invalid magic

      222 |     let src: Cell;
      223 |     if (Buffer.isBuffer(args.src)) {
    > 224 |         src = Cell.fromBoc(args.src)[0];
          |                    ^
      225 |     } else {
      226 |         src = args.src;
      227 |     }

      at parseBoc (node_modules/@ton/core/dist/boc/cell/serialization.js:160:15)
      at deserializeBoc (node_modules/@ton/core/dist/boc/cell/serialization.js:168:15)
      at Function.fromBoc (node_modules/@ton/core/dist/boc/Cell.js:34:51)
      at decompileAll (src/decompiler/decompileAll.ts:224:20)
      at Object.<anonymous> (src/decompiler/decompileAll.spec.ts:70:31)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, wow! let's open an issue in the @ton/core repo then and link it here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, my bad! I forgot that func writes a fift output by default, not BOC. I'll replace the file.

Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks! I didn't check the decompiled code is equivalent to the original code, opened an issue for that #17

@anton-trunov anton-trunov merged commit 3fbebd4 into tact-lang:main Jul 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants