Skip to content

Commit

Permalink
chore: merge upstream/main
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpy committed Apr 28, 2024
2 parents 08ba95e + ce31cad commit 94f4dcd
Show file tree
Hide file tree
Showing 37 changed files with 2,251 additions and 395 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/tact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
run: |
yarn lint:schema
- name: Show an example .pkg file on Windows
if: runner.os == 'Windows'
run: |
type examples\output\echo_Echo.pkg
- name: Compare Tact version from CLI flag `--version` against package.json
if: runner.os != 'Windows'
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist
output/
src/grammar/grammar.ohm-bundle.js
src/grammar/grammar.ohm-bundle.d.ts
src/func/funcfiftlib.wasm.js

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `pow2` power function with base 2: PR [#267](https://github.com/tact-lang/tact/pull/267)
- The `try` and `try-catch` statements: PR [#212](https://github.com/tact-lang/tact/pull/212)
- The `--func` and `--check` flags: PR [#287](https://github.com/tact-lang/tact/pull/287)
- The `del` method for the `Map` type: PR [#95](https://github.com/tact-lang/tact/pull/95)

### Changed

Expand All @@ -33,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `dump()` and `dumpStack()` functions now print the file path, line number, and column number in addition to the data: PR [#271](https://github.com/tact-lang/tact/pull/271)
- Use `|` instead of `+` for send mode flags because the bitwise OR operation is idempotent and hence safer: PR [#274](https://github.com/tact-lang/tact/pull/274)
- Bumped the versions of `@ton/core` and `ohm-js` to the most recent ones: PR [#276](https://github.com/tact-lang/tact/pull/276)
- Generated `.pkg`-files always use POSIX file paths (even on Windows): PR [# 300](https://github.com/tact-lang/tact/pull/300)

### Fixed

Expand All @@ -46,6 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- FunC compilation errors when trying to `dump()` values of the `Cell`, `Slice`, `Builder` and `StringBuilder` types: PR [#271](https://github.com/tact-lang/tact/pull/271)
- Tact's CLI returns a non-zero exit code if compilation fails: PR [#278](https://github.com/tact-lang/tact/pull/278)
- Use the most recent version of the FunC standard library [`stdlib.fc`](https://github.com/ton-blockchain/ton/blob/4cfe1d1a96acf956e28e2bbc696a143489e23631/crypto/smartcont/stdlib.fc): PR [#283](https://github.com/tact-lang/tact/pull/283)
- The WASM version of the FunC compiler has been updated to 0.4.4 and patched to work on larger contracts: PR [#297](https://github.com/tact-lang/tact/pull/297)
- The `return`-statement reachability analysis: PR [#302](https://github.com/tact-lang/tact/pull/302)

## [1.2.0] - 2024-02-29

Expand Down
35 changes: 35 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Tact release checklist template

- [ ] Improve the changelog for `vX.Y.Z`: grammar, wording, polishing
- [ ] Make sure there are no open issues for the [vX.Y.Z milestone](https://github.com/tact-lang/tact/issues?q=is%3Aopen+is%3Aissue+milestone%3AvX.Y.Z)
(except for the current one, of course)
- [ ] Bump Tact version in:
- [ ] [`package.json`](./package.json) file
- [ ] [`bin/tact`](./bin/tact) file
- [ ] [CHANGELOG.md](./CHANGELOG.md): `Unreleased` -> `vX.Y.Z`
- [ ] Tag the new `vX.Y.Z` release in Git
```shell
$ git tag -a vX.Y.Z
$ git push origin vX.Y.Z
```
- [ ] Create the new `vX.Y.Z` release on GitHub: <https://github.com/tact-lang/tact/releases>
- [ ] Publish the new `vX.Y.Z` release on NPM:
[@tact-lang/compiler](https://www.npmjs.com/package/@tact-lang/compiler)
```shell
$ git checkout vX.Y.Z
$ yarn all && npm publish
```
- [ ] Update [tact-docs](https://github.com/tact-lang/tact-docs) with the most recent Tact features
- [ ] Request or perform the plugins/parsers/tools updates and releases:
- [ ] <https://github.com/tact-lang/tree-sitter-tact>
- [ ] <https://github.com/tact-lang/tact.vim>
- [ ] <https://github.com/tact-lang/tact-template>
- [ ] <https://github.com/tact-lang/tact-vscode>
- [ ] A new release of [tact-vscode](https://marketplace.visualstudio.com/items?itemName=KonVik.tact-lang-vscode) on the Visual Studio Marketplace
- [ ] <https://github.com/novusnota/prism-ton>
- [ ] <https://github.com/nujan-io/nujan-ide>
- [ ] <https://github.com/ton-org/blueprint>
- [ ] <https://github.com/ton-blockchain/intellij-ton>
- [ ] Write `vX.Y.Z` release notes explaining the newest changes with code examples and commit those to this repository
- [ ] [TON Dev News](https://t.me/tondev_news) Telegram channel announcement
- [ ] Accumulate TON dev chats feedback
67 changes: 67 additions & 0 deletions src/abi/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,73 @@ export const MapFunctions: Map<string, AbiFunction> = new Map([
},
},
],
[
"del",
{
name: "del",
resolve(ctx, args, ref) {
// Check arguments
if (args.length !== 2) {
throwError("del expects one argument", ref); // Ignore self argument
}
const self = args[0];
if (!self || self.kind !== "map") {
throwError("del expects a map as self argument", ref); // Should not happen
}

// Check key type
if (args[1].kind !== "ref" || args[1].optional) {
throwError(
"del expects a direct type as first argument",
ref,
);
}
if (args[1].name !== self.key) {
throwError(
`del expects a ${self.key} as first argument`,
ref,
);
}

// Returns boolean
return { kind: "ref", name: "Bool", optional: false };
},
generate: (ctx, args, exprs, ref) => {
if (args.length !== 2) {
throwError("del expects one argument", ref); // Ignore self argument
}
const self = args[0];
if (!self || self.kind !== "map") {
throwError("del expects a map as self argument", ref); // Should not happen
}

// Render expressions
const resolved = exprs.map((v) => writeExpression(v, ctx));

// Handle Int key
if (self.key === "Int") {
let bits = 257;
let kind = "int";
if (self.keyAs && self.keyAs.startsWith("int")) {
bits = parseInt(self.keyAs.slice(3), 10);
} else if (self.keyAs && self.keyAs.startsWith("uint")) {
bits = parseInt(self.keyAs.slice(4), 10);
kind = "uint";
}
ctx.used(`__tact_dict_delete_${kind}`);
return `${resolved[0]}~__tact_dict_delete_${kind}(${bits}, ${resolved[1]})`;
}

// Handle Address key
if (self.key === "Address") {
ctx.used(`__tact_dict_delete`);
return `${resolved[0]}~__tact_dict_delete(267, ${resolved[1]})`;
}

throwError(`del expects a map with Int keys`, ref);
},
},
],
[
"asCell",
{
Expand Down
2 changes: 1 addition & 1 deletion src/func/funcfiftlib.js

Large diffs are not rendered by default.

Binary file modified src/func/funcfiftlib.wasm
Binary file not shown.
1 change: 0 additions & 1 deletion src/func/funcfiftlib.wasm.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/generator/writeProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export async function writeProgram(

const remainingFunctions = tryExtractModule(functions, null, imported);
const header: string[] = [];
header.push("#pragma version =0.4.3;");
header.push("#pragma version =0.4.4;");
header.push("#pragma allow-post-modification;");
header.push("#pragma compute-asm-ltr;");
header.push("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,30 @@ return __tact_create_address(chain, hash);",
"name": "__tact_dict_delete",
"signature": "(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)",
},
{
"code": {
"code": "asm(index dict key_len) "DICTIDEL"",
"kind": "asm",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {},
"name": "__tact_dict_delete_int",
"signature": "(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)",
},
{
"code": {
"code": "asm(index dict key_len) "DICTUDEL"",
"kind": "asm",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {},
"name": "__tact_dict_delete_uint",
"signature": "(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)",
},
{
"code": {
"code": "asm(value index dict key_len) "DICTSETREF"",
Expand Down Expand Up @@ -4275,6 +4299,30 @@ return __tact_create_address(chain, hash);",
"name": "__tact_dict_delete",
"signature": "(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)",
},
{
"code": {
"code": "asm(index dict key_len) "DICTIDEL"",
"kind": "asm",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {},
"name": "__tact_dict_delete_int",
"signature": "(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)",
},
{
"code": {
"code": "asm(index dict key_len) "DICTUDEL"",
"kind": "asm",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {},
"name": "__tact_dict_delete_uint",
"signature": "(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)",
},
{
"code": {
"code": "asm(value index dict key_len) "DICTSETREF"",
Expand Down Expand Up @@ -8315,6 +8363,30 @@ return __tact_create_address(chain, hash);",
"name": "__tact_dict_delete",
"signature": "(cell, int) __tact_dict_delete(cell dict, int key_len, slice index)",
},
{
"code": {
"code": "asm(index dict key_len) "DICTIDEL"",
"kind": "asm",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {},
"name": "__tact_dict_delete_int",
"signature": "(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)",
},
{
"code": {
"code": "asm(index dict key_len) "DICTUDEL"",
"kind": "asm",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {},
"name": "__tact_dict_delete_uint",
"signature": "(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)",
},
{
"code": {
"code": "asm(value index dict key_len) "DICTSETREF"",
Expand Down
16 changes: 16 additions & 0 deletions src/generator/writers/writeStdlib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ export function writeStdlib(ctx: WriterContext) {
ctx.asm(`asm(index dict key_len) "DICTDEL"`);
});

ctx.fun("__tact_dict_delete_int", () => {
ctx.signature(
`(cell, int) __tact_dict_delete_int(cell dict, int key_len, int index)`,
);
ctx.context("stdlib");
ctx.asm(`asm(index dict key_len) "DICTIDEL"`);
});

ctx.fun("__tact_dict_delete_uint", () => {
ctx.signature(
`(cell, int) __tact_dict_delete_uint(cell dict, int key_len, int index)`,
);
ctx.context("stdlib");
ctx.asm(`asm(index dict key_len) "DICTUDEL"`);
});

ctx.fun("__tact_dict_set_ref", () => {
ctx.signature(
`((cell), ()) __tact_dict_set_ref(cell dict, int key_len, slice index, cell value)`,
Expand Down
Loading

0 comments on commit 94f4dcd

Please sign in to comment.