Skip to content

Commit

Permalink
feat: functions with asm bodies (#769)
Browse files Browse the repository at this point in the history
and port the Tact stdlib to use `asm` function where feasible

It also updates the minimal required Node.js version to 22,
because it has `isSubsetOf` function on sets
  • Loading branch information
anton-trunov authored Aug 31, 2024
1 parent 12def54 commit 2ac7000
Show file tree
Hide file tree
Showing 56 changed files with 2,509 additions and 643 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [20]
node-version: [22]
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `toSlice` method for structs and messages: PR [#630](https://github.com/tact-lang/tact/pull/630)
- Wider range of serialization options for integers — `uint1` through `uint256` and `int1` through `int257`: PR [#558](https://github.com/tact-lang/tact/pull/558)
- The `deepEquals` method for the `Map` type: PR [#637](https://github.com/tact-lang/tact/pull/637)
- `asm` bodies for module-level functions: PR [#769](https://github.com/tact-lang/tact/pull/769)

### Changed

Expand All @@ -22,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- References to declared global constants.
- Allow omitting semicolons in contract/trait declarations and definitions: PR [#718](https://github.com/tact-lang/tact/pull/718)
- Compiler Tests are now using `@ton/sandbox` instead of `@tact-lang/emulator`: PR [#651](https://github.com/tact-lang/tact/pull/651)
- The required node.js version is bumped to 22: PR [#769](https://github.com/tact-lang/tact/pull/769)

### Fixed

Expand Down
45 changes: 44 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.2",
"language": "en",
"words": [
"ADDRAND",
"alnum",
"assgn",
"augmentedassign",
Expand All @@ -27,6 +28,7 @@
"funs",
"funcfiftlib",
"funcid",
"HASHEXT",
"idict",
"initof",
"infixl",
Expand All @@ -35,10 +37,15 @@
"ipld",
"jettons",
"jsxdev",
"keccak",
"KECCAK",
"knip",
"Laika",
"LDIX",
"langle",
"LDVARUINT",
"lparen",
"LTIME",
"lvalue",
"lvalues",
"masterchain",
Expand All @@ -48,6 +55,7 @@
"mktemp",
"multiformats",
"Korshakov",
"NEWC",
"nocheck",
"noexcept",
"Nonterminal",
Expand All @@ -57,22 +65,30 @@
"Parens",
"POSIX",
"prando",
"RANDU",
"rangle",
"rparen",
"rugpull",
"rugpulled",
"sctx",
"STIX",
"STUX",
"STVARUINT",
"STREF",
"seqno",
"shiki",
"Stateinit",
"STDICT",
"stdlib",
"struct",
"structs",
"subtyping",
"Tarjan",
"testdata",
"THROWIFNOT",
"Topup",
"typechecker",
"UBITSIZE",
"udict",
"uintptr",
"uncons",
Expand All @@ -86,7 +102,34 @@
"Brujin",
"dentry",
"SETINDEXVARQ",
"gettest"
"gettest",
"LDREF",
"STSLICER",
"ENDC",
"BREFS",
"BBITS",
"CTOS",
"PLDREF",
"LDSLICEX",
"PLDSLICEX",
"PLDIX",
"LDUX",
"PLDUX",
"SDSKIPFIRST",
"SREFS",
"SBITS",
"SEMPTY",
"SDEMPTY",
"SREMPTY",
"CONFIGOPTPARAM",
"MYADDR",
"HASHCU",
"HASHSU",
"CHKSIGNU",
"CHKSIGNS",
"RAWRESERVE",
"SENDRAWMSG",
"SDBEGINSQ"
],
"flagWords": [],
"ignorePaths": [
Expand Down
4 changes: 3 additions & 1 deletion src/generator/Writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Body =
}
| {
kind: "asm";
shuffle: string;
code: string;
}
| {
Expand Down Expand Up @@ -212,10 +213,11 @@ export class WriterContext {
});
}

asm(code: string) {
asm(shuffle: string, code: string) {
if (this.#pendingName) {
this.#pendingCode = {
kind: "asm",
shuffle,
code,
};
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/generator/emitter/emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function emit(args: {
if (f.flags.has("impure")) {
sig = `${sig} impure`;
}
res += `${sig} ${f.code.code};`;
res += `${sig} asm${f.code.shuffle} "${f.code.code}";`;
} else {
throw new Error(`Unknown function body kind`);
}
Expand Down
Loading

0 comments on commit 2ac7000

Please sign in to comment.