-
Notifications
You must be signed in to change notification settings - Fork 24
feat: tolk-asm-functions #1561
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
base: main
Are you sure you want to change the base?
feat: tolk-asm-functions #1561
Conversation
|
/review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update to languages/tolk/features/asm-functions.mdx: there’s one inline suggestion to clarify the asm argument ordering, so please apply the inline suggestion.
| Sometimes a function accepts parameters in an order different from what a TVM instruction expects. For example, `GETSTORAGEFEE` expects the parameters in the order cells, bits, seconds, and workchain. For a clearer API, the function should take the workchain as its first argument. To reorder stack positions, use the `asm(<INPUT_ORDER>)` syntax: | ||
|
|
||
| ```tolk | ||
| fun calculateStorageFee(workchain: int8, seconds: int, bits: int, cells: int): coins | ||
| asm(cells bits seconds workchain) "GETSTORAGEFEE" | ||
| ``` | ||
|
|
||
| Similarly for return values. If multiple slots are returned, and they must be reordered to match typing, | ||
| use `asm(-> ...)` syntax: | ||
| Similarly for return values. If multiple slots are returned and must be reordered to match typing, use the `asm(-> <RETURN_ORDER>)` syntax: | ||
|
|
||
| ```tolk | ||
| fun asmLoadCoins(s: slice): (slice, int) | ||
| asm(-> 1 0) "LDVARUINT16" | ||
| ``` | ||
|
|
||
| Both the input and output sides may be combined: `asm(... -> ...)`. | ||
| Reordering is mostly used with `mutate` variables. | ||
| Both the input and output sides can be combined: `asm(<INPUT_ORDER> -> <RETURN_ORDER>)`. Reordering is mostly used with `mutate` variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HIGH] Undefined <INPUT_ORDER> and <RETURN_ORDER> placeholders in asm syntax
The section “Stack-based argument reordering” introduces the inline forms asm(<INPUT_ORDER>), asm(-> <RETURN_ORDER>), and asm(<INPUT_ORDER> -> <RETURN_ORDER>) without defining what <INPUT_ORDER> and <RETURN_ORDER> represent. Because the surrounding text otherwise uses concrete argument orders (for example, asm(cells bits seconds workchain) and asm(-> 1 0)), these angle-bracket placeholders are ambiguous and can be misread as literal code to type. Per the style guide’s rule on global overrides and copy/paste hazards, leaving such placeholders undefined is treated as a high‑severity documentation issue. This ambiguity may cause readers to copy these snippets verbatim or remain uncertain about the expected format of these order values.
Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!
closes #1545