diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..6714668381 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run _cli.build.ts", + "type": "node", + "request": "launch", + "runtimeExecutable": "bash", + "args": [ + "-lc", + "clear; ts-node ${workspaceFolder}/src/next/test/_cli.build.ts ${file}" + ], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "env": { + "NODE_OPTIONS": "--stack-trace-limit=100000" + } + } + ] +} \ No newline at end of file diff --git a/find b/find new file mode 100644 index 0000000000..e69de29bb2 diff --git a/package.json b/package.json index 80839cc810..abbe08d708 100644 --- a/package.json +++ b/package.json @@ -119,6 +119,7 @@ "@types/glob": "^8.1.0", "@types/jest": "^29.5.12", "@types/node": "^22.5.0", + "@types/serialize-javascript": "^5.0.4", "@typescript-eslint/eslint-plugin": "^8.21.0", "@typescript-eslint/parser": "^8.21.0", "allure-commandline": "^2.34.0", @@ -140,6 +141,7 @@ "knip": "^5.24.1", "prando": "^6.0.1", "prettier": "^3.2.5", + "serialize-javascript": "^6.0.2", "rimraf": "^6.0.1", "ts-jest": "^29.0.3", "ts-node": "^10.9.1", diff --git a/result.js b/result.js new file mode 100644 index 0000000000..9f97d7b68e --- /dev/null +++ b/result.js @@ -0,0 +1,165818 @@ +Error: ./src/next/example/scope1-a.tact:2:1 - Declaration of "f" shadows previous declaration "f" + 1 | import "./scope1-b"; +> 2 | import "./scope1-c"; + ^~~~~~~~~~~~~~~~~~~~ + 3 | +{ + functions: Map(81) { + 'beginCell' => { + kind: 'tact', + path: 'std/internal/cells.tact', + code: '//\n' + + '// Builder\n' + + '//\n' + + '\n' + + '/// Creates a new empty `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#begincell\n' + + '///\n' + + 'asm fun beginCell(): Builder { NEWC }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a signed `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 257.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeInt(42, 7);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_int) // special treatment in Func compiler, so not replaced with asm "STIX"\n' + + 'extends native storeInt(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores an unsigned `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 256.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeUint(42, 6);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store a negative `value` or provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreuint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_uint) // special treatment in Func compiler, so not replaced with asm "STUX"\n' + + 'extends native storeUint(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `Bool` `value` into the copy of the `Builder`.\n' + + '/// Writes 1 as a single bit if `value` is `true`, and writes 0 otherwise.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBool(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBool(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorebool\n' + + '///\n' + + 'asm(value self) extends fun storeBool(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Alias to `Builder.storeBool()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBit(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBit(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebit\n' + + '///\n' + + 'asm(value self) extends fun storeBit(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^120 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 4-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^(8 * `l`), followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// This is the most common way of storing nanoToncoins.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeCoins(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeCoins(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Alias to `Builder.storeCoins()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint16(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorevaruint16\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + 'asm extends fun storeVarUint16(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeCoins()`, but with a different `value` range: from -2^119 to 2^119 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt16(-42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint16\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt16(self: Builder, value: Int): Builder { STVARINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^248 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 5-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^8 * `l`, followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint32(420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevaruint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarUint32(self: Builder, value: Int): Builder { STVARUINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeVarUint32()`, but with a different `value` range: from -2^247 to 2^247 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt32(-420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt32(self: Builder, value: Int): Builder { STVARINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a reference `cell` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeRef(emptyCell());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreref\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeRef(self: Builder, cell: Cell): Builder { STREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `slice` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let s: Slice = emptyCell().asSlice();\n' + + '/// let fizz: Builder = b.storeSlice(s);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreslice\n' + + '///\n' + + 'asm extends fun storeSlice(self: Builder, slice: Slice): Builder { STSLICER }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Appends all data from the `other` builder to the copy of the `self` builder. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(op: Int, queryId: Int, payload: Builder) {\n' + + '/// let msgBody = beginCell().storeUint(op, 32).storeUint(queryId, 64);\n' + + '/// if (payload.bits() != 0) {\n' + + '/// msgBody = msgBody.storeBuilder(payload); // assignment is important here\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebuilder\n' + + '///\n' + + 'asm extends fun storeBuilder(self: Builder, other: Builder): Builder { STBR }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// If the `cell` is not `null`, stores 1 as a single bit and then reference `cell` into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// If the `cell` is `null`, only stores 0 as a single bit into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b\n' + + '/// .storeMaybeRef(emptyCell()) // 1, then empty cell\n' + + '/// .storeMaybeRef(null); // 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoremayberef\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeMaybeRef(self: Builder, cell: Cell?): Builder { STOPTREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Converts a `Builder` into an ordinary `Cell`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let c: Cell = b.endCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/'... 40707 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginCell', + loc: { start: 218, end: 227 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 231, end: 238 } }, + loc: { start: 231, end: 238 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NEWC' ] + }, + loc: { start: 210, end: 247 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeInt', + loc: { start: 984, end: 992 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1032, end: 1039 } }, + loc: { start: 1032, end: 1039 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1008, end: 1013 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1008, end: 1018 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1020, end: 1024 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1020, end: 1029 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_int', + loc: { start: 887, end: 896 } + } + }, + loc: { start: 881, end: 1040 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 999, end: 1006 } }, + loc: { start: 999, end: 1006 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeUint', + loc: { start: 1817, end: 1826 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1866, end: 1873 } }, + loc: { start: 1866, end: 1873 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1842, end: 1847 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1842, end: 1852 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1854, end: 1858 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1854, end: 1863 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_uint', + loc: { start: 1719, end: 1729 } + } + }, + loc: { start: 1713, end: 1874 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1833, end: 1840 } }, + loc: { start: 1833, end: 1840 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBool', + loc: { start: 2420, end: 2429 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2459, end: 2466 } }, + loc: { start: 2459, end: 2466 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2445, end: 2450 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2452, end: 2456 } + }, + typeArgs: [], + loc: { start: 2452, end: 2456 } + }, + loc: { start: 2445, end: 2456 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2396, end: 2401 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2402, end: 2406 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2392, end: 2476 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2436, end: 2443 } }, + loc: { start: 2436, end: 2443 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBit', + loc: { start: 2902, end: 2910 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2940, end: 2947 } }, + loc: { start: 2940, end: 2947 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2926, end: 2931 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2933, end: 2937 } + }, + typeArgs: [], + loc: { start: 2933, end: 2937 } + }, + loc: { start: 2926, end: 2937 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2878, end: 2883 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2884, end: 2888 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2874, end: 2957 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2917, end: 2924 } }, + loc: { start: 2917, end: 2924 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeCoins', + loc: { start: 3902, end: 3912 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 3941, end: 3948 } }, + loc: { start: 3941, end: 3948 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 3928, end: 3933 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3928, end: 3938 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 3886, end: 3964 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 3919, end: 3926 } }, + loc: { start: 3919, end: 3926 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint16', + loc: { start: 4389, end: 4403 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 4432, end: 4439 } }, + loc: { start: 4432, end: 4439 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 4419, end: 4424 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4419, end: 4429 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 4373, end: 4455 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 4410, end: 4417 } }, + loc: { start: 4410, end: 4417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt16', + loc: { start: 5096, end: 5109 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 5138, end: 5145 } }, + loc: { start: 5138, end: 5145 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 5125, end: 5130 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5125, end: 5135 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT16' ] + }, + loc: { start: 5080, end: 5160 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 5116, end: 5123 } }, + loc: { start: 5116, end: 5123 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint32', + loc: { start: 6082, end: 6096 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6125, end: 6132 } }, + loc: { start: 6125, end: 6132 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6112, end: 6117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6112, end: 6122 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT32' ] + }, + loc: { start: 6066, end: 6148 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6103, end: 6110 } }, + loc: { start: 6103, end: 6110 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt32', + loc: { start: 6797, end: 6810 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6839, end: 6846 } }, + loc: { start: 6839, end: 6846 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6826, end: 6831 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6826, end: 6836 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT32' ] + }, + loc: { start: 6781, end: 6861 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6817, end: 6824 } }, + loc: { start: 6817, end: 6824 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeRef', + loc: { start: 7529, end: 7537 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 7566, end: 7573 } }, + loc: { start: 7566, end: 7573 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 7553, end: 7557 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7553, end: 7563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 7506, end: 7510 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 7511, end: 7515 } + } + ], + ret: [] + }, + instructions: [ 'STREF' ] + }, + loc: { start: 7502, end: 7583 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 7544, end: 7551 } }, + loc: { start: 7544, end: 7551 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeSlice', + loc: { start: 8005, end: 8015 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8046, end: 8053 } }, + loc: { start: 8046, end: 8053 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 8031, end: 8036 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8031, end: 8043 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 7989, end: 8066 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8022, end: 8029 } }, + loc: { start: 8022, end: 8029 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBuilder', + loc: { start: 8633, end: 8645 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8678, end: 8685 } }, + loc: { start: 8678, end: 8685 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'other', + loc: { start: 8661, end: 8666 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8661, end: 8675 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STBR' ] + }, + loc: { start: 8617, end: 8694 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8652, end: 8659 } }, + loc: { start: 8652, end: 8659 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeMaybeRef', + loc: { start: 9622, end: 9635 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9665, end: 9672 } }, + loc: { start: 9665, end: 9672 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 9651, end: 9655 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9661, end: 9662 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9657, end: 9661 } + }, + loc: { start: 9657, end: 9661 } + } + ], + loc: { start: 9661, end: 9662 } + }, + loc: { start: 9651, end: 9662 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 9599, end: 9603 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 9604, end: 9608 } + } + ], + ret: [] + }, + instructions: [ 'STOPTREF' ] + }, + loc: { start: 9595, end: 9685 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9642, end: 9649 } }, + loc: { start: 9642, end: 9649 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endCell', + loc: { start: 10082, end: 10089 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 10106, end: 10110 } + }, + loc: { start: 10106, end: 10110 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDC' ] + }, + loc: { start: 10066, end: 10119 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10096, end: 10103 } }, + loc: { start: 10096, end: 10103 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 10479, end: 10483 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10500, end: 10503 } + }, + loc: { start: 10500, end: 10503 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BREFS' ] + }, + loc: { start: 10463, end: 10513 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10490, end: 10497 } }, + loc: { start: 10490, end: 10497 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 10867, end: 10871 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10888, end: 10891 } + }, + loc: { start: 10888, end: 10891 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BBITS' ] + }, + loc: { start: 10851, end: 10901 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10878, end: 10885 } }, + loc: { start: 10878, end: 10885 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 11403, end: 11408 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11425, end: 11428 } + }, + loc: { start: 11425, end: 11428 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BDEPTH' ] + }, + loc: { start: 11387, end: 11439 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11415, end: 11422 } }, + loc: { start: 11415, end: 11422 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginParse', + loc: { start: 11787, end: 11797 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 11811, end: 11816 } + }, + loc: { start: 11811, end: 11816 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CTOS' ] + }, + loc: { start: 11771, end: 11825 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 11804, end: 11808 } }, + loc: { start: 11804, end: 11808 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadRef', + loc: { start: 12822, end: 12829 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 12844, end: 12848 } + }, + loc: { start: 12844, end: 12848 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 12797, end: 12798 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 12799, end: 12800 } + } + ] + }, + instructions: [ 'LDREF' ] + }, + loc: { start: 12790, end: 12858 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 12836, end: 12841 } }, + loc: { start: 12836, end: 12841 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipRef', + loc: { start: 13772, end: 13779 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDREF NIP' ] + }, + loc: { start: 13748, end: 13806 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 13786, end: 13791 } }, + loc: { start: 13786, end: 13791 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadRef', + loc: { start: 14937, end: 14947 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 14962, end: 14966 } + }, + loc: { start: 14962, end: 14966 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDREF' ] + }, + loc: { start: 14921, end: 14977 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 14954, end: 14959 } }, + loc: { start: 14954, end: 14959 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadMaybeRef', + loc: { start: 16024, end: 16036 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 16055, end: 16056 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16051, end: 16055 } + }, + loc: { start: 16051, end: 16055 } + } + ], + loc: { start: 16055, end: 16056 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15999, end: 16000 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 16001, end: 16002 } + } + ] + }, + instructions: [ 'LDOPTREF' ] + }, + loc: { start: 15992, end: 16069 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 16043, end: 16048 } }, + loc: { start: 16043, end: 16048 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipMaybeRef', + loc: { start: 17041, end: 17053 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDOPTREF NIP' ] + }, + loc: { start: 17017, end: 17083 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 17060, end: 17065 } }, + loc: { start: 17060, end: 17065 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadMaybeRef', + loc: { start: 18449, end: 18464 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 18483, end: 18484 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 18479, end: 18483 } + }, + loc: { start: 18479, end: 18483 } + } + ], + loc: { start: 18483, end: 18484 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDOPTREF' ] + }, + loc: { start: 18433, end: 18498 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 18471, end: 18476 } }, + loc: { start: 18471, end: 18476 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBits', + loc: { start: 19377, end: 19385 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 19408, end: 19413 } + }, + loc: { start: 19408, end: 19413 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 19399, end: 19400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19399, end: 19405 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_bits', + loc: { start: 19268, end: 19277 } + } + }, + loc: { start: 19262, end: 19414 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 19392, end: 19397 } }, + loc: { start: 19392, end: 19397 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadBits', + loc: { start: 20333, end: 20344 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 20367, end: 20372 } + }, + loc: { start: 20367, end: 20372 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 20358, end: 20359 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20358, end: 20364 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_bits', + loc: { start: 20228, end: 20240 } + } + }, + loc: { start: 20222, end: 20373 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 20351, end: 20356 } }, + loc: { start: 20351, end: 20356 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadInt', + loc: { start: 21236, end: 21243 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21266, end: 21269 } + }, + loc: { start: 21266, end: 21269 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 21257, end: 21258 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21257, end: 21263 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_int', + loc: { start: 21132, end: 21140 } + } + }, + loc: { start: 21126, end: 21270 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 21250, end: 21255 } }, + loc: { start: 21250, end: 21255 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadInt', + loc: { start: 22164, end: 22174 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22197, end: 22200 } + }, + loc: { start: 22197, end: 22200 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 22188, end: 22189 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22188, end: 22194 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_int', + loc: { start: 22064, end: 22075 } + } + }, + loc: { start: 22058, end: 22201 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 22181, end: 22186 } }, + loc: { start: 22181, end: 22186 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadUint', + loc: { start: 23071, end: 23079 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23102, end: 23105 } + }, + loc: { start: 23102, end: 23105 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 23093, end: 23094 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23093, end: 23099 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_uint', + loc: { start: 22966, end: 22975 } + } + }, + loc: { start: 22960, end: 23106 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 23086, end: 23091 } }, + loc: { start: 23086, end: 23091 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadUint', + loc: { start: 24007, end: 24018 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24041, end: 24044 } + }, + loc: { start: 24041, end: 24044 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 24032, end: 24033 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24032, end: 24038 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_uint', + loc: { start: 23906, end: 23918 } + } + }, + loc: { start: 23900, end: 24045 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 24025, end: 24030 } }, + loc: { start: 24025, end: 24030 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBool', + loc: { start: 24834, end: 24842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 24857, end: 24861 } + }, + typeArgs: [], + loc: { start: 24857, end: 24861 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 24809, end: 24810 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 24811, end: 24812 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 24802, end: 24871 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 24849, end: 24854 } }, + loc: { start: 24849, end: 24854 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBool', + loc: { start: 25769, end: 25777 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '1 LDI NIP' ] + }, + loc: { start: 25745, end: 25804 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 25784, end: 25789 } }, + loc: { start: 25784, end: 25789 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBit', + loc: { start: 26558, end: 26565 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 26580, end: 26584 } + }, + typeArgs: [], + loc: { start: 26580, end: 26584 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 26533, end: 26534 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 26535, end: 26536 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 26526, end: 26594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 26572, end: 26577 } }, + loc: { start: 26572, end: 26577 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadCoins', + loc: { start: 27454, end: 27463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 27478, end: 27481 } + }, + loc: { start: 27478, end: 27481 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 27429, end: 27430 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 27431, end: 27432 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 27422, end: 27497 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 27470, end: 27475 } }, + loc: { start: 27470, end: 27475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipCoins', + loc: { start: 28454, end: 28463 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 28430, end: 28496 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 28470, end: 28475 } }, + loc: { start: 28470, end: 28475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint16', + loc: { start: 29318, end: 29331 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 29346, end: 29349 } + }, + loc: { start: 29346, end: 29349 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 29293, end: 29294 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 29295, end: 29296 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 29286, end: 29365 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 29338, end: 29343 } }, + loc: { start: 29338, end: 29343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint16', + loc: { start: 30263, end: 30276 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 30239, end: 30309 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 30283, end: 30288 } }, + loc: { start: 30283, end: 30288 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt16', + loc: { start: 31141, end: 31153 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 31168, end: 31171 } + }, + loc: { start: 31168, end: 31171 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 31116, end: 31117 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 31118, end: 31119 } + } + ] + }, + instructions: [ 'LDVARINT16' ] + }, + loc: { start: 31109, end: 31186 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 31160, end: 31165 } }, + loc: { start: 31160, end: 31165 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt16', + loc: { start: 32093, end: 32105 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT16 NIP' ] + }, + loc: { start: 32069, end: 32137 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 32112, end: 32117 } }, + loc: { start: 32112, end: 32117 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint32', + loc: { start: 32987, end: 33000 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 33015, end: 33018 } + }, + loc: { start: 33015, end: 33018 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 32962, end: 32963 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 32964, end: 32965 } + } + ] + }, + instructions: [ 'LDVARUINT32' ] + }, + loc: { start: 32955, end: 33034 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 33007, end: 33012 } }, + loc: { start: 33007, end: 33012 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint32', + loc: { start: 34007, end: 34020 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT32 NIP' ] + }, + loc: { start: 33983, end: 34053 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 34027, end: 34032 } }, + loc: { start: 34027, end: 34032 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt32', + loc: { start: 34897, end: 34909 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 34924, end: 34927 } + }, + loc: { start: 34924, end: 34927 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 34872, end: 34873 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 34874, end: 34875 } + } + ] + }, + instructions: [ 'LDVARINT32' ] + }, + loc: { start: 34865, end: 34942 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 34916, end: 34921 } }, + loc: { start: 34916, end: 34921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt32', + loc: { start: 35854, end: 35866 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT32 NIP' ] + }, + loc: { start: 35830, end: 35898 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 35873, end: 35878 } }, + loc: { start: 35873, end: 35878 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBits', + loc: { start: 36746, end: 36754 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 36768, end: 36769 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36768, end: 36774 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPFIRST' ] + }, + loc: { start: 36722, end: 36791 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 36761, end: 36766 } }, + loc: { start: 36761, end: 36766 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endParse', + loc: { start: 37397, end: 37405 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDS' ] + }, + loc: { start: 37381, end: 37427 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 37412, end: 37417 } }, + loc: { start: 37412, end: 37417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipLastBits', + loc: { start: 38319, end: 38331 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 38356, end: 38361 } + }, + loc: { start: 38356, end: 38361 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 38345, end: 38348 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38345, end: 38353 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPLAST' ] + }, + loc: { start: 38303, end: 38376 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 38338, end: 38343 } }, + loc: { start: 38338, end: 38343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'firstBits', + loc: { start: 39373, end: 39382 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 39407, end: 39412 } + }, + loc: { start: 39407, end: 39412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 39396, end: 39399 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39396, end: 39404 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTFIRST' ] + }, + loc: { start: 39357, end: 39427 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 39389, end: 39394 } }, + loc: { start: 39389, end: 39394 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'lastBits', + loc: { start: 40218, end: 40226 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 40251, end: 40256 } + }, + loc: { start: 40251, end: 40256 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 40240, end: 40243 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40240, end: 40248 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTLAST' ] + }, + loc: { start: 40202, end: 40270 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 40233, end: 40238 } }, + loc: { start: 40233, end: 40238 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 40758, end: 40763 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40778, end: 40781 } + }, + loc: { start: 40778, end: 40781 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEPTH' ] + }, + loc: { start: 40742, end: 40792 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 40770, end: 40775 } }, + loc: { start: 40770, end: 40775 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 41166, end: 41170 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41185, end: 41188 } + }, + loc: { start: 41185, end: 41188 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREFS' ] + }, + loc: { start: 41150, end: 41198 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 41177, end: 41182 } }, + loc: { start: 41177, end: 41182 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 41550, end: 41554 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41569, end: 41572 } + }, + loc: { start: 41569, end: 41572 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SBITS' ] + }, + loc: { start: 41534, end: 41582 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 41561, end: 41566 } }, + loc: { start: 41561, end: 41566 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'empty', + loc: { start: 42117, end: 42122 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42137, end: 42141 } + }, + typeArgs: [], + loc: { start: 42137, end: 42141 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SEMPTY' ] + }, + loc: { start: 42101, end: 42152 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 42129, end: 42134 } }, + loc: { start: 42129, end: 42134 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'dataEmpty', + loc: { start: 42682, end: 42691 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42706, end: 42710 } + }, + typeArgs: [], + loc: { start: 42706, end: 42710 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEMPTY' ] + }, + loc: { start: 42666, end: 42722 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 42698, end: 42703 } }, + loc: { start: 42698, end: 42703 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refsEmpty', + loc: { start: 43231, end: 43240 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 43255, end: 43259 } + }, + typeArgs: [], + loc: { start: 43255, end: 43259 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREMPTY' ] + }, + loc: { start: 43215, end: 43271 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 43247, end: 43252 } }, + loc: { start: 43247, end: 43252 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 43671, end: 43678 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 43695, end: 43700 } + }, + loc: { start: 43695, end: 43700 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 43714, end: 43718 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 43719, end: 43726 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43728 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 43729, end: 43739 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43741 } + }, + loc: { start: 43707, end: 43742 } + } + ] + }, + loc: { start: 43652, end: 43744 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 43685, end: 43692 } }, + loc: { start: 43685, end: 43692 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 44098, end: 44105 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 44119, end: 44124 } + }, + loc: { start: 44119, end: 44124 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 44138, end: 44142 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 44143, end: 44153 } + }, + typeArgs: [], + args: [], + loc: { start: 44138, end: 44155 } + }, + loc: { start: 44131, end: 44156 } + } + ] + }, + loc: { start: 44079, end: 44158 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 44112, end: 44116 } }, + loc: { start: 44112, end: 44116 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 44714, end: 44720 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 44735, end: 44739 } + }, + loc: { start: 44735, end: 44739 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 44753, end: 44762 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44764 } + }, + method: { + kind: 'id', + text: 'storeSlice', + loc: { start: 44774, end: 44784 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 44785, end: 44789 } + } + ], + loc: { start: 44753, end: 44790 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 44800, end: 44807 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44809 } + }, + loc: { start: 44746, end: 44810 } + } + ] + }, + loc: { start: 44695, end: 44812 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 44727, end: 44732 } }, + loc: { start: 44727, end: 44732 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 45173, end: 45179 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 45196, end: 45200 } + }, + loc: { start: 45196, end: 45200 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 45214, end: 45218 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 45219, end: 45226 } + }, + typeArgs: [], + args: [], + loc: { start: 45214, end: 45228 } + }, + loc: { start: 45207, end: 45229 } + } + ] + }, + loc: { start: 45154, end: 45231 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 45186, end: 45193 } }, + loc: { start: 45186, end: 45193 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptyCell', + loc: { start: 45592, end: 45601 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 45605, end: 45609 } }, + loc: { start: 45605, end: 45609 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + ' PUSHREF // Pure Fift: "" turns it into a cell at compile time' + ] + }, + loc: { start: 45584, end: 45711 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptySlice', + loc: { start: 46077, end: 46087 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 46091, end: 46096 } }, + loc: { start: 46091, end: 46096 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'b{} PUSHSLICE' ] + }, + loc: { start: 46069, end: 46118 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 46431, end: 46439 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'cells', + loc: { start: 46516, end: 46521 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46523, end: 46526 } + }, + loc: { start: 46523, end: 46526 } + }, + initializer: undefined, + loc: { start: 46516, end: 46526 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bits', + loc: { start: 46615, end: 46619 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46621, end: 46624 } + }, + loc: { start: 46621, end: 46624 } + }, + initializer: undefined, + loc: { start: 46615, end: 46624 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'refs', + loc: { start: 46713, end: 46717 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46719, end: 46722 } + }, + loc: { start: 46719, end: 46722 } + }, + initializer: undefined, + loc: { start: 46713, end: 46722 } + } + ], + loc: { start: 46424, end: 46725 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 48450, end: 48465 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 48495, end: 48503 } + }, + typeArgs: [], + loc: { start: 48495, end: 48503 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 48479, end: 48487 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48479, end: 48492 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDATASIZE' ] + }, + loc: { start: 48434, end: 48517 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 48476, end: 48477 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 48472, end: 48476 } + }, + loc: { start: 48472, end: 48476 } + } + ], + loc: { start: 48476, end: 48477 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 50094, end: 50109 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 50139, end: 50147 } + }, + typeArgs: [], + loc: { start: 50139, end: 50147 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 50123, end: 50131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50123, end: 50136 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDATASIZE' ] + }, + loc: { start: 50078, end: 50161 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 50116, end: 50121 } }, + loc: { start: 50116, end: 50121 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 50672, end: 50677 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50692, end: 50695 } + }, + loc: { start: 50692, end: 50695 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDEPTH' ] + }, + loc: { start: 50656, end: 50706 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 50688, end: 50689 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 50684, end: 50688 } + }, + loc: { start: 50684, end: 50688 } + } + ], + loc: { start: 50688, end: 50689 } + } + } + ] + }, + 'emptyCell' => { + kind: 'tact', + path: 'std/internal/cells.tact', + code: '//\n' + + '// Builder\n' + + '//\n' + + '\n' + + '/// Creates a new empty `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#begincell\n' + + '///\n' + + 'asm fun beginCell(): Builder { NEWC }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a signed `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 257.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeInt(42, 7);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_int) // special treatment in Func compiler, so not replaced with asm "STIX"\n' + + 'extends native storeInt(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores an unsigned `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 256.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeUint(42, 6);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store a negative `value` or provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreuint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_uint) // special treatment in Func compiler, so not replaced with asm "STUX"\n' + + 'extends native storeUint(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `Bool` `value` into the copy of the `Builder`.\n' + + '/// Writes 1 as a single bit if `value` is `true`, and writes 0 otherwise.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBool(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBool(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorebool\n' + + '///\n' + + 'asm(value self) extends fun storeBool(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Alias to `Builder.storeBool()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBit(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBit(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebit\n' + + '///\n' + + 'asm(value self) extends fun storeBit(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^120 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 4-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^(8 * `l`), followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// This is the most common way of storing nanoToncoins.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeCoins(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeCoins(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Alias to `Builder.storeCoins()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint16(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorevaruint16\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + 'asm extends fun storeVarUint16(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeCoins()`, but with a different `value` range: from -2^119 to 2^119 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt16(-42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint16\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt16(self: Builder, value: Int): Builder { STVARINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^248 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 5-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^8 * `l`, followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint32(420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevaruint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarUint32(self: Builder, value: Int): Builder { STVARUINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeVarUint32()`, but with a different `value` range: from -2^247 to 2^247 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt32(-420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt32(self: Builder, value: Int): Builder { STVARINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a reference `cell` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeRef(emptyCell());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreref\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeRef(self: Builder, cell: Cell): Builder { STREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `slice` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let s: Slice = emptyCell().asSlice();\n' + + '/// let fizz: Builder = b.storeSlice(s);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreslice\n' + + '///\n' + + 'asm extends fun storeSlice(self: Builder, slice: Slice): Builder { STSLICER }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Appends all data from the `other` builder to the copy of the `self` builder. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(op: Int, queryId: Int, payload: Builder) {\n' + + '/// let msgBody = beginCell().storeUint(op, 32).storeUint(queryId, 64);\n' + + '/// if (payload.bits() != 0) {\n' + + '/// msgBody = msgBody.storeBuilder(payload); // assignment is important here\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebuilder\n' + + '///\n' + + 'asm extends fun storeBuilder(self: Builder, other: Builder): Builder { STBR }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// If the `cell` is not `null`, stores 1 as a single bit and then reference `cell` into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// If the `cell` is `null`, only stores 0 as a single bit into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b\n' + + '/// .storeMaybeRef(emptyCell()) // 1, then empty cell\n' + + '/// .storeMaybeRef(null); // 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoremayberef\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeMaybeRef(self: Builder, cell: Cell?): Builder { STOPTREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Converts a `Builder` into an ordinary `Cell`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let c: Cell = b.endCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/'... 40707 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginCell', + loc: { start: 218, end: 227 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 231, end: 238 } }, + loc: { start: 231, end: 238 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NEWC' ] + }, + loc: { start: 210, end: 247 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeInt', + loc: { start: 984, end: 992 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1032, end: 1039 } }, + loc: { start: 1032, end: 1039 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1008, end: 1013 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1008, end: 1018 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1020, end: 1024 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1020, end: 1029 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_int', + loc: { start: 887, end: 896 } + } + }, + loc: { start: 881, end: 1040 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 999, end: 1006 } }, + loc: { start: 999, end: 1006 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeUint', + loc: { start: 1817, end: 1826 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1866, end: 1873 } }, + loc: { start: 1866, end: 1873 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1842, end: 1847 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1842, end: 1852 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1854, end: 1858 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1854, end: 1863 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_uint', + loc: { start: 1719, end: 1729 } + } + }, + loc: { start: 1713, end: 1874 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1833, end: 1840 } }, + loc: { start: 1833, end: 1840 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBool', + loc: { start: 2420, end: 2429 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2459, end: 2466 } }, + loc: { start: 2459, end: 2466 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2445, end: 2450 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2452, end: 2456 } + }, + typeArgs: [], + loc: { start: 2452, end: 2456 } + }, + loc: { start: 2445, end: 2456 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2396, end: 2401 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2402, end: 2406 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2392, end: 2476 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2436, end: 2443 } }, + loc: { start: 2436, end: 2443 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBit', + loc: { start: 2902, end: 2910 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2940, end: 2947 } }, + loc: { start: 2940, end: 2947 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2926, end: 2931 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2933, end: 2937 } + }, + typeArgs: [], + loc: { start: 2933, end: 2937 } + }, + loc: { start: 2926, end: 2937 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2878, end: 2883 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2884, end: 2888 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2874, end: 2957 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2917, end: 2924 } }, + loc: { start: 2917, end: 2924 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeCoins', + loc: { start: 3902, end: 3912 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 3941, end: 3948 } }, + loc: { start: 3941, end: 3948 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 3928, end: 3933 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3928, end: 3938 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 3886, end: 3964 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 3919, end: 3926 } }, + loc: { start: 3919, end: 3926 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint16', + loc: { start: 4389, end: 4403 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 4432, end: 4439 } }, + loc: { start: 4432, end: 4439 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 4419, end: 4424 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4419, end: 4429 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 4373, end: 4455 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 4410, end: 4417 } }, + loc: { start: 4410, end: 4417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt16', + loc: { start: 5096, end: 5109 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 5138, end: 5145 } }, + loc: { start: 5138, end: 5145 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 5125, end: 5130 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5125, end: 5135 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT16' ] + }, + loc: { start: 5080, end: 5160 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 5116, end: 5123 } }, + loc: { start: 5116, end: 5123 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint32', + loc: { start: 6082, end: 6096 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6125, end: 6132 } }, + loc: { start: 6125, end: 6132 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6112, end: 6117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6112, end: 6122 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT32' ] + }, + loc: { start: 6066, end: 6148 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6103, end: 6110 } }, + loc: { start: 6103, end: 6110 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt32', + loc: { start: 6797, end: 6810 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6839, end: 6846 } }, + loc: { start: 6839, end: 6846 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6826, end: 6831 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6826, end: 6836 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT32' ] + }, + loc: { start: 6781, end: 6861 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6817, end: 6824 } }, + loc: { start: 6817, end: 6824 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeRef', + loc: { start: 7529, end: 7537 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 7566, end: 7573 } }, + loc: { start: 7566, end: 7573 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 7553, end: 7557 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7553, end: 7563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 7506, end: 7510 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 7511, end: 7515 } + } + ], + ret: [] + }, + instructions: [ 'STREF' ] + }, + loc: { start: 7502, end: 7583 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 7544, end: 7551 } }, + loc: { start: 7544, end: 7551 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeSlice', + loc: { start: 8005, end: 8015 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8046, end: 8053 } }, + loc: { start: 8046, end: 8053 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 8031, end: 8036 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8031, end: 8043 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 7989, end: 8066 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8022, end: 8029 } }, + loc: { start: 8022, end: 8029 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBuilder', + loc: { start: 8633, end: 8645 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8678, end: 8685 } }, + loc: { start: 8678, end: 8685 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'other', + loc: { start: 8661, end: 8666 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8661, end: 8675 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STBR' ] + }, + loc: { start: 8617, end: 8694 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8652, end: 8659 } }, + loc: { start: 8652, end: 8659 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeMaybeRef', + loc: { start: 9622, end: 9635 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9665, end: 9672 } }, + loc: { start: 9665, end: 9672 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 9651, end: 9655 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9661, end: 9662 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9657, end: 9661 } + }, + loc: { start: 9657, end: 9661 } + } + ], + loc: { start: 9661, end: 9662 } + }, + loc: { start: 9651, end: 9662 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 9599, end: 9603 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 9604, end: 9608 } + } + ], + ret: [] + }, + instructions: [ 'STOPTREF' ] + }, + loc: { start: 9595, end: 9685 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9642, end: 9649 } }, + loc: { start: 9642, end: 9649 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endCell', + loc: { start: 10082, end: 10089 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 10106, end: 10110 } + }, + loc: { start: 10106, end: 10110 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDC' ] + }, + loc: { start: 10066, end: 10119 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10096, end: 10103 } }, + loc: { start: 10096, end: 10103 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 10479, end: 10483 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10500, end: 10503 } + }, + loc: { start: 10500, end: 10503 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BREFS' ] + }, + loc: { start: 10463, end: 10513 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10490, end: 10497 } }, + loc: { start: 10490, end: 10497 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 10867, end: 10871 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10888, end: 10891 } + }, + loc: { start: 10888, end: 10891 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BBITS' ] + }, + loc: { start: 10851, end: 10901 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10878, end: 10885 } }, + loc: { start: 10878, end: 10885 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 11403, end: 11408 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11425, end: 11428 } + }, + loc: { start: 11425, end: 11428 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BDEPTH' ] + }, + loc: { start: 11387, end: 11439 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11415, end: 11422 } }, + loc: { start: 11415, end: 11422 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginParse', + loc: { start: 11787, end: 11797 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 11811, end: 11816 } + }, + loc: { start: 11811, end: 11816 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CTOS' ] + }, + loc: { start: 11771, end: 11825 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 11804, end: 11808 } }, + loc: { start: 11804, end: 11808 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadRef', + loc: { start: 12822, end: 12829 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 12844, end: 12848 } + }, + loc: { start: 12844, end: 12848 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 12797, end: 12798 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 12799, end: 12800 } + } + ] + }, + instructions: [ 'LDREF' ] + }, + loc: { start: 12790, end: 12858 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 12836, end: 12841 } }, + loc: { start: 12836, end: 12841 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipRef', + loc: { start: 13772, end: 13779 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDREF NIP' ] + }, + loc: { start: 13748, end: 13806 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 13786, end: 13791 } }, + loc: { start: 13786, end: 13791 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadRef', + loc: { start: 14937, end: 14947 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 14962, end: 14966 } + }, + loc: { start: 14962, end: 14966 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDREF' ] + }, + loc: { start: 14921, end: 14977 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 14954, end: 14959 } }, + loc: { start: 14954, end: 14959 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadMaybeRef', + loc: { start: 16024, end: 16036 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 16055, end: 16056 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16051, end: 16055 } + }, + loc: { start: 16051, end: 16055 } + } + ], + loc: { start: 16055, end: 16056 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15999, end: 16000 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 16001, end: 16002 } + } + ] + }, + instructions: [ 'LDOPTREF' ] + }, + loc: { start: 15992, end: 16069 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 16043, end: 16048 } }, + loc: { start: 16043, end: 16048 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipMaybeRef', + loc: { start: 17041, end: 17053 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDOPTREF NIP' ] + }, + loc: { start: 17017, end: 17083 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 17060, end: 17065 } }, + loc: { start: 17060, end: 17065 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadMaybeRef', + loc: { start: 18449, end: 18464 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 18483, end: 18484 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 18479, end: 18483 } + }, + loc: { start: 18479, end: 18483 } + } + ], + loc: { start: 18483, end: 18484 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDOPTREF' ] + }, + loc: { start: 18433, end: 18498 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 18471, end: 18476 } }, + loc: { start: 18471, end: 18476 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBits', + loc: { start: 19377, end: 19385 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 19408, end: 19413 } + }, + loc: { start: 19408, end: 19413 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 19399, end: 19400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19399, end: 19405 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_bits', + loc: { start: 19268, end: 19277 } + } + }, + loc: { start: 19262, end: 19414 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 19392, end: 19397 } }, + loc: { start: 19392, end: 19397 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadBits', + loc: { start: 20333, end: 20344 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 20367, end: 20372 } + }, + loc: { start: 20367, end: 20372 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 20358, end: 20359 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20358, end: 20364 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_bits', + loc: { start: 20228, end: 20240 } + } + }, + loc: { start: 20222, end: 20373 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 20351, end: 20356 } }, + loc: { start: 20351, end: 20356 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadInt', + loc: { start: 21236, end: 21243 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21266, end: 21269 } + }, + loc: { start: 21266, end: 21269 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 21257, end: 21258 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21257, end: 21263 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_int', + loc: { start: 21132, end: 21140 } + } + }, + loc: { start: 21126, end: 21270 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 21250, end: 21255 } }, + loc: { start: 21250, end: 21255 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadInt', + loc: { start: 22164, end: 22174 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22197, end: 22200 } + }, + loc: { start: 22197, end: 22200 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 22188, end: 22189 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22188, end: 22194 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_int', + loc: { start: 22064, end: 22075 } + } + }, + loc: { start: 22058, end: 22201 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 22181, end: 22186 } }, + loc: { start: 22181, end: 22186 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadUint', + loc: { start: 23071, end: 23079 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23102, end: 23105 } + }, + loc: { start: 23102, end: 23105 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 23093, end: 23094 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23093, end: 23099 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_uint', + loc: { start: 22966, end: 22975 } + } + }, + loc: { start: 22960, end: 23106 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 23086, end: 23091 } }, + loc: { start: 23086, end: 23091 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadUint', + loc: { start: 24007, end: 24018 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24041, end: 24044 } + }, + loc: { start: 24041, end: 24044 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 24032, end: 24033 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24032, end: 24038 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_uint', + loc: { start: 23906, end: 23918 } + } + }, + loc: { start: 23900, end: 24045 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 24025, end: 24030 } }, + loc: { start: 24025, end: 24030 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBool', + loc: { start: 24834, end: 24842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 24857, end: 24861 } + }, + typeArgs: [], + loc: { start: 24857, end: 24861 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 24809, end: 24810 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 24811, end: 24812 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 24802, end: 24871 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 24849, end: 24854 } }, + loc: { start: 24849, end: 24854 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBool', + loc: { start: 25769, end: 25777 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '1 LDI NIP' ] + }, + loc: { start: 25745, end: 25804 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 25784, end: 25789 } }, + loc: { start: 25784, end: 25789 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBit', + loc: { start: 26558, end: 26565 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 26580, end: 26584 } + }, + typeArgs: [], + loc: { start: 26580, end: 26584 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 26533, end: 26534 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 26535, end: 26536 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 26526, end: 26594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 26572, end: 26577 } }, + loc: { start: 26572, end: 26577 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadCoins', + loc: { start: 27454, end: 27463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 27478, end: 27481 } + }, + loc: { start: 27478, end: 27481 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 27429, end: 27430 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 27431, end: 27432 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 27422, end: 27497 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 27470, end: 27475 } }, + loc: { start: 27470, end: 27475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipCoins', + loc: { start: 28454, end: 28463 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 28430, end: 28496 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 28470, end: 28475 } }, + loc: { start: 28470, end: 28475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint16', + loc: { start: 29318, end: 29331 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 29346, end: 29349 } + }, + loc: { start: 29346, end: 29349 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 29293, end: 29294 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 29295, end: 29296 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 29286, end: 29365 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 29338, end: 29343 } }, + loc: { start: 29338, end: 29343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint16', + loc: { start: 30263, end: 30276 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 30239, end: 30309 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 30283, end: 30288 } }, + loc: { start: 30283, end: 30288 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt16', + loc: { start: 31141, end: 31153 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 31168, end: 31171 } + }, + loc: { start: 31168, end: 31171 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 31116, end: 31117 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 31118, end: 31119 } + } + ] + }, + instructions: [ 'LDVARINT16' ] + }, + loc: { start: 31109, end: 31186 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 31160, end: 31165 } }, + loc: { start: 31160, end: 31165 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt16', + loc: { start: 32093, end: 32105 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT16 NIP' ] + }, + loc: { start: 32069, end: 32137 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 32112, end: 32117 } }, + loc: { start: 32112, end: 32117 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint32', + loc: { start: 32987, end: 33000 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 33015, end: 33018 } + }, + loc: { start: 33015, end: 33018 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 32962, end: 32963 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 32964, end: 32965 } + } + ] + }, + instructions: [ 'LDVARUINT32' ] + }, + loc: { start: 32955, end: 33034 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 33007, end: 33012 } }, + loc: { start: 33007, end: 33012 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint32', + loc: { start: 34007, end: 34020 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT32 NIP' ] + }, + loc: { start: 33983, end: 34053 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 34027, end: 34032 } }, + loc: { start: 34027, end: 34032 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt32', + loc: { start: 34897, end: 34909 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 34924, end: 34927 } + }, + loc: { start: 34924, end: 34927 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 34872, end: 34873 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 34874, end: 34875 } + } + ] + }, + instructions: [ 'LDVARINT32' ] + }, + loc: { start: 34865, end: 34942 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 34916, end: 34921 } }, + loc: { start: 34916, end: 34921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt32', + loc: { start: 35854, end: 35866 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT32 NIP' ] + }, + loc: { start: 35830, end: 35898 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 35873, end: 35878 } }, + loc: { start: 35873, end: 35878 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBits', + loc: { start: 36746, end: 36754 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 36768, end: 36769 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36768, end: 36774 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPFIRST' ] + }, + loc: { start: 36722, end: 36791 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 36761, end: 36766 } }, + loc: { start: 36761, end: 36766 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endParse', + loc: { start: 37397, end: 37405 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDS' ] + }, + loc: { start: 37381, end: 37427 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 37412, end: 37417 } }, + loc: { start: 37412, end: 37417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipLastBits', + loc: { start: 38319, end: 38331 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 38356, end: 38361 } + }, + loc: { start: 38356, end: 38361 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 38345, end: 38348 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38345, end: 38353 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPLAST' ] + }, + loc: { start: 38303, end: 38376 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 38338, end: 38343 } }, + loc: { start: 38338, end: 38343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'firstBits', + loc: { start: 39373, end: 39382 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 39407, end: 39412 } + }, + loc: { start: 39407, end: 39412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 39396, end: 39399 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39396, end: 39404 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTFIRST' ] + }, + loc: { start: 39357, end: 39427 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 39389, end: 39394 } }, + loc: { start: 39389, end: 39394 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'lastBits', + loc: { start: 40218, end: 40226 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 40251, end: 40256 } + }, + loc: { start: 40251, end: 40256 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 40240, end: 40243 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40240, end: 40248 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTLAST' ] + }, + loc: { start: 40202, end: 40270 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 40233, end: 40238 } }, + loc: { start: 40233, end: 40238 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 40758, end: 40763 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40778, end: 40781 } + }, + loc: { start: 40778, end: 40781 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEPTH' ] + }, + loc: { start: 40742, end: 40792 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 40770, end: 40775 } }, + loc: { start: 40770, end: 40775 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 41166, end: 41170 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41185, end: 41188 } + }, + loc: { start: 41185, end: 41188 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREFS' ] + }, + loc: { start: 41150, end: 41198 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 41177, end: 41182 } }, + loc: { start: 41177, end: 41182 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 41550, end: 41554 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41569, end: 41572 } + }, + loc: { start: 41569, end: 41572 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SBITS' ] + }, + loc: { start: 41534, end: 41582 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 41561, end: 41566 } }, + loc: { start: 41561, end: 41566 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'empty', + loc: { start: 42117, end: 42122 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42137, end: 42141 } + }, + typeArgs: [], + loc: { start: 42137, end: 42141 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SEMPTY' ] + }, + loc: { start: 42101, end: 42152 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 42129, end: 42134 } }, + loc: { start: 42129, end: 42134 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'dataEmpty', + loc: { start: 42682, end: 42691 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42706, end: 42710 } + }, + typeArgs: [], + loc: { start: 42706, end: 42710 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEMPTY' ] + }, + loc: { start: 42666, end: 42722 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 42698, end: 42703 } }, + loc: { start: 42698, end: 42703 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refsEmpty', + loc: { start: 43231, end: 43240 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 43255, end: 43259 } + }, + typeArgs: [], + loc: { start: 43255, end: 43259 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREMPTY' ] + }, + loc: { start: 43215, end: 43271 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 43247, end: 43252 } }, + loc: { start: 43247, end: 43252 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 43671, end: 43678 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 43695, end: 43700 } + }, + loc: { start: 43695, end: 43700 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 43714, end: 43718 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 43719, end: 43726 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43728 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 43729, end: 43739 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43741 } + }, + loc: { start: 43707, end: 43742 } + } + ] + }, + loc: { start: 43652, end: 43744 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 43685, end: 43692 } }, + loc: { start: 43685, end: 43692 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 44098, end: 44105 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 44119, end: 44124 } + }, + loc: { start: 44119, end: 44124 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 44138, end: 44142 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 44143, end: 44153 } + }, + typeArgs: [], + args: [], + loc: { start: 44138, end: 44155 } + }, + loc: { start: 44131, end: 44156 } + } + ] + }, + loc: { start: 44079, end: 44158 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 44112, end: 44116 } }, + loc: { start: 44112, end: 44116 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 44714, end: 44720 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 44735, end: 44739 } + }, + loc: { start: 44735, end: 44739 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 44753, end: 44762 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44764 } + }, + method: { + kind: 'id', + text: 'storeSlice', + loc: { start: 44774, end: 44784 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 44785, end: 44789 } + } + ], + loc: { start: 44753, end: 44790 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 44800, end: 44807 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44809 } + }, + loc: { start: 44746, end: 44810 } + } + ] + }, + loc: { start: 44695, end: 44812 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 44727, end: 44732 } }, + loc: { start: 44727, end: 44732 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 45173, end: 45179 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 45196, end: 45200 } + }, + loc: { start: 45196, end: 45200 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 45214, end: 45218 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 45219, end: 45226 } + }, + typeArgs: [], + args: [], + loc: { start: 45214, end: 45228 } + }, + loc: { start: 45207, end: 45229 } + } + ] + }, + loc: { start: 45154, end: 45231 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 45186, end: 45193 } }, + loc: { start: 45186, end: 45193 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptyCell', + loc: { start: 45592, end: 45601 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 45605, end: 45609 } }, + loc: { start: 45605, end: 45609 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + ' PUSHREF // Pure Fift: "" turns it into a cell at compile time' + ] + }, + loc: { start: 45584, end: 45711 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptySlice', + loc: { start: 46077, end: 46087 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 46091, end: 46096 } }, + loc: { start: 46091, end: 46096 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'b{} PUSHSLICE' ] + }, + loc: { start: 46069, end: 46118 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 46431, end: 46439 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'cells', + loc: { start: 46516, end: 46521 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46523, end: 46526 } + }, + loc: { start: 46523, end: 46526 } + }, + initializer: undefined, + loc: { start: 46516, end: 46526 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bits', + loc: { start: 46615, end: 46619 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46621, end: 46624 } + }, + loc: { start: 46621, end: 46624 } + }, + initializer: undefined, + loc: { start: 46615, end: 46624 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'refs', + loc: { start: 46713, end: 46717 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46719, end: 46722 } + }, + loc: { start: 46719, end: 46722 } + }, + initializer: undefined, + loc: { start: 46713, end: 46722 } + } + ], + loc: { start: 46424, end: 46725 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 48450, end: 48465 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 48495, end: 48503 } + }, + typeArgs: [], + loc: { start: 48495, end: 48503 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 48479, end: 48487 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48479, end: 48492 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDATASIZE' ] + }, + loc: { start: 48434, end: 48517 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 48476, end: 48477 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 48472, end: 48476 } + }, + loc: { start: 48472, end: 48476 } + } + ], + loc: { start: 48476, end: 48477 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 50094, end: 50109 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 50139, end: 50147 } + }, + typeArgs: [], + loc: { start: 50139, end: 50147 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 50123, end: 50131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50123, end: 50136 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDATASIZE' ] + }, + loc: { start: 50078, end: 50161 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 50116, end: 50121 } }, + loc: { start: 50116, end: 50121 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 50672, end: 50677 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50692, end: 50695 } + }, + loc: { start: 50692, end: 50695 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDEPTH' ] + }, + loc: { start: 50656, end: 50706 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 50688, end: 50689 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 50684, end: 50688 } + }, + loc: { start: 50684, end: 50688 } + } + ], + loc: { start: 50688, end: 50689 } + } + } + ] + }, + 'emptySlice' => { + kind: 'tact', + path: 'std/internal/cells.tact', + code: '//\n' + + '// Builder\n' + + '//\n' + + '\n' + + '/// Creates a new empty `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#begincell\n' + + '///\n' + + 'asm fun beginCell(): Builder { NEWC }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a signed `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 257.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeInt(42, 7);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_int) // special treatment in Func compiler, so not replaced with asm "STIX"\n' + + 'extends native storeInt(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores an unsigned `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 256.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeUint(42, 6);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store a negative `value` or provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreuint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_uint) // special treatment in Func compiler, so not replaced with asm "STUX"\n' + + 'extends native storeUint(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `Bool` `value` into the copy of the `Builder`.\n' + + '/// Writes 1 as a single bit if `value` is `true`, and writes 0 otherwise.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBool(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBool(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorebool\n' + + '///\n' + + 'asm(value self) extends fun storeBool(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Alias to `Builder.storeBool()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBit(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBit(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebit\n' + + '///\n' + + 'asm(value self) extends fun storeBit(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^120 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 4-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^(8 * `l`), followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// This is the most common way of storing nanoToncoins.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeCoins(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeCoins(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Alias to `Builder.storeCoins()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint16(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorevaruint16\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + 'asm extends fun storeVarUint16(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeCoins()`, but with a different `value` range: from -2^119 to 2^119 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt16(-42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint16\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt16(self: Builder, value: Int): Builder { STVARINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^248 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 5-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^8 * `l`, followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint32(420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevaruint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarUint32(self: Builder, value: Int): Builder { STVARUINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeVarUint32()`, but with a different `value` range: from -2^247 to 2^247 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt32(-420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt32(self: Builder, value: Int): Builder { STVARINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a reference `cell` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeRef(emptyCell());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreref\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeRef(self: Builder, cell: Cell): Builder { STREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `slice` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let s: Slice = emptyCell().asSlice();\n' + + '/// let fizz: Builder = b.storeSlice(s);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreslice\n' + + '///\n' + + 'asm extends fun storeSlice(self: Builder, slice: Slice): Builder { STSLICER }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Appends all data from the `other` builder to the copy of the `self` builder. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(op: Int, queryId: Int, payload: Builder) {\n' + + '/// let msgBody = beginCell().storeUint(op, 32).storeUint(queryId, 64);\n' + + '/// if (payload.bits() != 0) {\n' + + '/// msgBody = msgBody.storeBuilder(payload); // assignment is important here\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebuilder\n' + + '///\n' + + 'asm extends fun storeBuilder(self: Builder, other: Builder): Builder { STBR }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// If the `cell` is not `null`, stores 1 as a single bit and then reference `cell` into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// If the `cell` is `null`, only stores 0 as a single bit into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b\n' + + '/// .storeMaybeRef(emptyCell()) // 1, then empty cell\n' + + '/// .storeMaybeRef(null); // 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoremayberef\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeMaybeRef(self: Builder, cell: Cell?): Builder { STOPTREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Converts a `Builder` into an ordinary `Cell`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let c: Cell = b.endCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/'... 40707 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginCell', + loc: { start: 218, end: 227 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 231, end: 238 } }, + loc: { start: 231, end: 238 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NEWC' ] + }, + loc: { start: 210, end: 247 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeInt', + loc: { start: 984, end: 992 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1032, end: 1039 } }, + loc: { start: 1032, end: 1039 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1008, end: 1013 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1008, end: 1018 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1020, end: 1024 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1020, end: 1029 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_int', + loc: { start: 887, end: 896 } + } + }, + loc: { start: 881, end: 1040 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 999, end: 1006 } }, + loc: { start: 999, end: 1006 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeUint', + loc: { start: 1817, end: 1826 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1866, end: 1873 } }, + loc: { start: 1866, end: 1873 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1842, end: 1847 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1842, end: 1852 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1854, end: 1858 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1854, end: 1863 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_uint', + loc: { start: 1719, end: 1729 } + } + }, + loc: { start: 1713, end: 1874 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1833, end: 1840 } }, + loc: { start: 1833, end: 1840 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBool', + loc: { start: 2420, end: 2429 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2459, end: 2466 } }, + loc: { start: 2459, end: 2466 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2445, end: 2450 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2452, end: 2456 } + }, + typeArgs: [], + loc: { start: 2452, end: 2456 } + }, + loc: { start: 2445, end: 2456 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2396, end: 2401 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2402, end: 2406 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2392, end: 2476 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2436, end: 2443 } }, + loc: { start: 2436, end: 2443 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBit', + loc: { start: 2902, end: 2910 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2940, end: 2947 } }, + loc: { start: 2940, end: 2947 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2926, end: 2931 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2933, end: 2937 } + }, + typeArgs: [], + loc: { start: 2933, end: 2937 } + }, + loc: { start: 2926, end: 2937 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2878, end: 2883 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2884, end: 2888 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2874, end: 2957 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 2917, end: 2924 } }, + loc: { start: 2917, end: 2924 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeCoins', + loc: { start: 3902, end: 3912 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 3941, end: 3948 } }, + loc: { start: 3941, end: 3948 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 3928, end: 3933 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3928, end: 3938 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 3886, end: 3964 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 3919, end: 3926 } }, + loc: { start: 3919, end: 3926 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint16', + loc: { start: 4389, end: 4403 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 4432, end: 4439 } }, + loc: { start: 4432, end: 4439 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 4419, end: 4424 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4419, end: 4429 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 4373, end: 4455 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 4410, end: 4417 } }, + loc: { start: 4410, end: 4417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt16', + loc: { start: 5096, end: 5109 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 5138, end: 5145 } }, + loc: { start: 5138, end: 5145 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 5125, end: 5130 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5125, end: 5135 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT16' ] + }, + loc: { start: 5080, end: 5160 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 5116, end: 5123 } }, + loc: { start: 5116, end: 5123 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint32', + loc: { start: 6082, end: 6096 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6125, end: 6132 } }, + loc: { start: 6125, end: 6132 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6112, end: 6117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6112, end: 6122 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT32' ] + }, + loc: { start: 6066, end: 6148 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6103, end: 6110 } }, + loc: { start: 6103, end: 6110 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt32', + loc: { start: 6797, end: 6810 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6839, end: 6846 } }, + loc: { start: 6839, end: 6846 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6826, end: 6831 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6826, end: 6836 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT32' ] + }, + loc: { start: 6781, end: 6861 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 6817, end: 6824 } }, + loc: { start: 6817, end: 6824 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeRef', + loc: { start: 7529, end: 7537 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 7566, end: 7573 } }, + loc: { start: 7566, end: 7573 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 7553, end: 7557 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7553, end: 7563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 7506, end: 7510 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 7511, end: 7515 } + } + ], + ret: [] + }, + instructions: [ 'STREF' ] + }, + loc: { start: 7502, end: 7583 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 7544, end: 7551 } }, + loc: { start: 7544, end: 7551 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeSlice', + loc: { start: 8005, end: 8015 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8046, end: 8053 } }, + loc: { start: 8046, end: 8053 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 8031, end: 8036 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8031, end: 8043 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 7989, end: 8066 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8022, end: 8029 } }, + loc: { start: 8022, end: 8029 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBuilder', + loc: { start: 8633, end: 8645 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8678, end: 8685 } }, + loc: { start: 8678, end: 8685 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'other', + loc: { start: 8661, end: 8666 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8661, end: 8675 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STBR' ] + }, + loc: { start: 8617, end: 8694 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 8652, end: 8659 } }, + loc: { start: 8652, end: 8659 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeMaybeRef', + loc: { start: 9622, end: 9635 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9665, end: 9672 } }, + loc: { start: 9665, end: 9672 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 9651, end: 9655 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9661, end: 9662 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9657, end: 9661 } + }, + loc: { start: 9657, end: 9661 } + } + ], + loc: { start: 9661, end: 9662 } + }, + loc: { start: 9651, end: 9662 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 9599, end: 9603 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 9604, end: 9608 } + } + ], + ret: [] + }, + instructions: [ 'STOPTREF' ] + }, + loc: { start: 9595, end: 9685 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9642, end: 9649 } }, + loc: { start: 9642, end: 9649 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endCell', + loc: { start: 10082, end: 10089 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 10106, end: 10110 } + }, + loc: { start: 10106, end: 10110 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDC' ] + }, + loc: { start: 10066, end: 10119 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10096, end: 10103 } }, + loc: { start: 10096, end: 10103 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 10479, end: 10483 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10500, end: 10503 } + }, + loc: { start: 10500, end: 10503 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BREFS' ] + }, + loc: { start: 10463, end: 10513 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10490, end: 10497 } }, + loc: { start: 10490, end: 10497 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 10867, end: 10871 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10888, end: 10891 } + }, + loc: { start: 10888, end: 10891 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BBITS' ] + }, + loc: { start: 10851, end: 10901 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 10878, end: 10885 } }, + loc: { start: 10878, end: 10885 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 11403, end: 11408 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11425, end: 11428 } + }, + loc: { start: 11425, end: 11428 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BDEPTH' ] + }, + loc: { start: 11387, end: 11439 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11415, end: 11422 } }, + loc: { start: 11415, end: 11422 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginParse', + loc: { start: 11787, end: 11797 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 11811, end: 11816 } + }, + loc: { start: 11811, end: 11816 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CTOS' ] + }, + loc: { start: 11771, end: 11825 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 11804, end: 11808 } }, + loc: { start: 11804, end: 11808 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadRef', + loc: { start: 12822, end: 12829 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 12844, end: 12848 } + }, + loc: { start: 12844, end: 12848 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 12797, end: 12798 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 12799, end: 12800 } + } + ] + }, + instructions: [ 'LDREF' ] + }, + loc: { start: 12790, end: 12858 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 12836, end: 12841 } }, + loc: { start: 12836, end: 12841 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipRef', + loc: { start: 13772, end: 13779 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDREF NIP' ] + }, + loc: { start: 13748, end: 13806 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 13786, end: 13791 } }, + loc: { start: 13786, end: 13791 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadRef', + loc: { start: 14937, end: 14947 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 14962, end: 14966 } + }, + loc: { start: 14962, end: 14966 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDREF' ] + }, + loc: { start: 14921, end: 14977 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 14954, end: 14959 } }, + loc: { start: 14954, end: 14959 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadMaybeRef', + loc: { start: 16024, end: 16036 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 16055, end: 16056 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16051, end: 16055 } + }, + loc: { start: 16051, end: 16055 } + } + ], + loc: { start: 16055, end: 16056 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15999, end: 16000 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 16001, end: 16002 } + } + ] + }, + instructions: [ 'LDOPTREF' ] + }, + loc: { start: 15992, end: 16069 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 16043, end: 16048 } }, + loc: { start: 16043, end: 16048 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipMaybeRef', + loc: { start: 17041, end: 17053 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDOPTREF NIP' ] + }, + loc: { start: 17017, end: 17083 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 17060, end: 17065 } }, + loc: { start: 17060, end: 17065 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadMaybeRef', + loc: { start: 18449, end: 18464 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 18483, end: 18484 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 18479, end: 18483 } + }, + loc: { start: 18479, end: 18483 } + } + ], + loc: { start: 18483, end: 18484 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDOPTREF' ] + }, + loc: { start: 18433, end: 18498 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 18471, end: 18476 } }, + loc: { start: 18471, end: 18476 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBits', + loc: { start: 19377, end: 19385 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 19408, end: 19413 } + }, + loc: { start: 19408, end: 19413 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 19399, end: 19400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19399, end: 19405 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_bits', + loc: { start: 19268, end: 19277 } + } + }, + loc: { start: 19262, end: 19414 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 19392, end: 19397 } }, + loc: { start: 19392, end: 19397 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadBits', + loc: { start: 20333, end: 20344 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 20367, end: 20372 } + }, + loc: { start: 20367, end: 20372 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 20358, end: 20359 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20358, end: 20364 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_bits', + loc: { start: 20228, end: 20240 } + } + }, + loc: { start: 20222, end: 20373 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 20351, end: 20356 } }, + loc: { start: 20351, end: 20356 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadInt', + loc: { start: 21236, end: 21243 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21266, end: 21269 } + }, + loc: { start: 21266, end: 21269 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 21257, end: 21258 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21257, end: 21263 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_int', + loc: { start: 21132, end: 21140 } + } + }, + loc: { start: 21126, end: 21270 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 21250, end: 21255 } }, + loc: { start: 21250, end: 21255 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadInt', + loc: { start: 22164, end: 22174 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22197, end: 22200 } + }, + loc: { start: 22197, end: 22200 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 22188, end: 22189 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22188, end: 22194 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_int', + loc: { start: 22064, end: 22075 } + } + }, + loc: { start: 22058, end: 22201 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 22181, end: 22186 } }, + loc: { start: 22181, end: 22186 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadUint', + loc: { start: 23071, end: 23079 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23102, end: 23105 } + }, + loc: { start: 23102, end: 23105 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 23093, end: 23094 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23093, end: 23099 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_uint', + loc: { start: 22966, end: 22975 } + } + }, + loc: { start: 22960, end: 23106 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 23086, end: 23091 } }, + loc: { start: 23086, end: 23091 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadUint', + loc: { start: 24007, end: 24018 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24041, end: 24044 } + }, + loc: { start: 24041, end: 24044 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 24032, end: 24033 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24032, end: 24038 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_uint', + loc: { start: 23906, end: 23918 } + } + }, + loc: { start: 23900, end: 24045 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 24025, end: 24030 } }, + loc: { start: 24025, end: 24030 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBool', + loc: { start: 24834, end: 24842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 24857, end: 24861 } + }, + typeArgs: [], + loc: { start: 24857, end: 24861 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 24809, end: 24810 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 24811, end: 24812 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 24802, end: 24871 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 24849, end: 24854 } }, + loc: { start: 24849, end: 24854 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBool', + loc: { start: 25769, end: 25777 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '1 LDI NIP' ] + }, + loc: { start: 25745, end: 25804 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 25784, end: 25789 } }, + loc: { start: 25784, end: 25789 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBit', + loc: { start: 26558, end: 26565 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 26580, end: 26584 } + }, + typeArgs: [], + loc: { start: 26580, end: 26584 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 26533, end: 26534 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 26535, end: 26536 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 26526, end: 26594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 26572, end: 26577 } }, + loc: { start: 26572, end: 26577 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadCoins', + loc: { start: 27454, end: 27463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 27478, end: 27481 } + }, + loc: { start: 27478, end: 27481 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 27429, end: 27430 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 27431, end: 27432 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 27422, end: 27497 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 27470, end: 27475 } }, + loc: { start: 27470, end: 27475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipCoins', + loc: { start: 28454, end: 28463 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 28430, end: 28496 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 28470, end: 28475 } }, + loc: { start: 28470, end: 28475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint16', + loc: { start: 29318, end: 29331 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 29346, end: 29349 } + }, + loc: { start: 29346, end: 29349 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 29293, end: 29294 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 29295, end: 29296 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 29286, end: 29365 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 29338, end: 29343 } }, + loc: { start: 29338, end: 29343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint16', + loc: { start: 30263, end: 30276 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 30239, end: 30309 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 30283, end: 30288 } }, + loc: { start: 30283, end: 30288 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt16', + loc: { start: 31141, end: 31153 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 31168, end: 31171 } + }, + loc: { start: 31168, end: 31171 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 31116, end: 31117 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 31118, end: 31119 } + } + ] + }, + instructions: [ 'LDVARINT16' ] + }, + loc: { start: 31109, end: 31186 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 31160, end: 31165 } }, + loc: { start: 31160, end: 31165 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt16', + loc: { start: 32093, end: 32105 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT16 NIP' ] + }, + loc: { start: 32069, end: 32137 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 32112, end: 32117 } }, + loc: { start: 32112, end: 32117 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint32', + loc: { start: 32987, end: 33000 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 33015, end: 33018 } + }, + loc: { start: 33015, end: 33018 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 32962, end: 32963 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 32964, end: 32965 } + } + ] + }, + instructions: [ 'LDVARUINT32' ] + }, + loc: { start: 32955, end: 33034 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 33007, end: 33012 } }, + loc: { start: 33007, end: 33012 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint32', + loc: { start: 34007, end: 34020 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT32 NIP' ] + }, + loc: { start: 33983, end: 34053 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 34027, end: 34032 } }, + loc: { start: 34027, end: 34032 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt32', + loc: { start: 34897, end: 34909 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 34924, end: 34927 } + }, + loc: { start: 34924, end: 34927 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 34872, end: 34873 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 34874, end: 34875 } + } + ] + }, + instructions: [ 'LDVARINT32' ] + }, + loc: { start: 34865, end: 34942 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 34916, end: 34921 } }, + loc: { start: 34916, end: 34921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt32', + loc: { start: 35854, end: 35866 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT32 NIP' ] + }, + loc: { start: 35830, end: 35898 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 35873, end: 35878 } }, + loc: { start: 35873, end: 35878 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBits', + loc: { start: 36746, end: 36754 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 36768, end: 36769 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36768, end: 36774 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPFIRST' ] + }, + loc: { start: 36722, end: 36791 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 36761, end: 36766 } }, + loc: { start: 36761, end: 36766 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endParse', + loc: { start: 37397, end: 37405 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDS' ] + }, + loc: { start: 37381, end: 37427 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 37412, end: 37417 } }, + loc: { start: 37412, end: 37417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipLastBits', + loc: { start: 38319, end: 38331 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 38356, end: 38361 } + }, + loc: { start: 38356, end: 38361 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 38345, end: 38348 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38345, end: 38353 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPLAST' ] + }, + loc: { start: 38303, end: 38376 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 38338, end: 38343 } }, + loc: { start: 38338, end: 38343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'firstBits', + loc: { start: 39373, end: 39382 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 39407, end: 39412 } + }, + loc: { start: 39407, end: 39412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 39396, end: 39399 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39396, end: 39404 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTFIRST' ] + }, + loc: { start: 39357, end: 39427 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 39389, end: 39394 } }, + loc: { start: 39389, end: 39394 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'lastBits', + loc: { start: 40218, end: 40226 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 40251, end: 40256 } + }, + loc: { start: 40251, end: 40256 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 40240, end: 40243 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40240, end: 40248 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTLAST' ] + }, + loc: { start: 40202, end: 40270 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 40233, end: 40238 } }, + loc: { start: 40233, end: 40238 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 40758, end: 40763 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40778, end: 40781 } + }, + loc: { start: 40778, end: 40781 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEPTH' ] + }, + loc: { start: 40742, end: 40792 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 40770, end: 40775 } }, + loc: { start: 40770, end: 40775 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 41166, end: 41170 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41185, end: 41188 } + }, + loc: { start: 41185, end: 41188 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREFS' ] + }, + loc: { start: 41150, end: 41198 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 41177, end: 41182 } }, + loc: { start: 41177, end: 41182 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 41550, end: 41554 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41569, end: 41572 } + }, + loc: { start: 41569, end: 41572 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SBITS' ] + }, + loc: { start: 41534, end: 41582 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 41561, end: 41566 } }, + loc: { start: 41561, end: 41566 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'empty', + loc: { start: 42117, end: 42122 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42137, end: 42141 } + }, + typeArgs: [], + loc: { start: 42137, end: 42141 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SEMPTY' ] + }, + loc: { start: 42101, end: 42152 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 42129, end: 42134 } }, + loc: { start: 42129, end: 42134 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'dataEmpty', + loc: { start: 42682, end: 42691 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42706, end: 42710 } + }, + typeArgs: [], + loc: { start: 42706, end: 42710 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEMPTY' ] + }, + loc: { start: 42666, end: 42722 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 42698, end: 42703 } }, + loc: { start: 42698, end: 42703 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refsEmpty', + loc: { start: 43231, end: 43240 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 43255, end: 43259 } + }, + typeArgs: [], + loc: { start: 43255, end: 43259 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREMPTY' ] + }, + loc: { start: 43215, end: 43271 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 43247, end: 43252 } }, + loc: { start: 43247, end: 43252 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 43671, end: 43678 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 43695, end: 43700 } + }, + loc: { start: 43695, end: 43700 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 43714, end: 43718 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 43719, end: 43726 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43728 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 43729, end: 43739 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43741 } + }, + loc: { start: 43707, end: 43742 } + } + ] + }, + loc: { start: 43652, end: 43744 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 43685, end: 43692 } }, + loc: { start: 43685, end: 43692 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 44098, end: 44105 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 44119, end: 44124 } + }, + loc: { start: 44119, end: 44124 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 44138, end: 44142 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 44143, end: 44153 } + }, + typeArgs: [], + args: [], + loc: { start: 44138, end: 44155 } + }, + loc: { start: 44131, end: 44156 } + } + ] + }, + loc: { start: 44079, end: 44158 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 44112, end: 44116 } }, + loc: { start: 44112, end: 44116 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 44714, end: 44720 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 44735, end: 44739 } + }, + loc: { start: 44735, end: 44739 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 44753, end: 44762 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44764 } + }, + method: { + kind: 'id', + text: 'storeSlice', + loc: { start: 44774, end: 44784 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 44785, end: 44789 } + } + ], + loc: { start: 44753, end: 44790 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 44800, end: 44807 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44809 } + }, + loc: { start: 44746, end: 44810 } + } + ] + }, + loc: { start: 44695, end: 44812 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 44727, end: 44732 } }, + loc: { start: 44727, end: 44732 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 45173, end: 45179 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 45196, end: 45200 } + }, + loc: { start: 45196, end: 45200 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 45214, end: 45218 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 45219, end: 45226 } + }, + typeArgs: [], + args: [], + loc: { start: 45214, end: 45228 } + }, + loc: { start: 45207, end: 45229 } + } + ] + }, + loc: { start: 45154, end: 45231 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 45186, end: 45193 } }, + loc: { start: 45186, end: 45193 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptyCell', + loc: { start: 45592, end: 45601 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 45605, end: 45609 } }, + loc: { start: 45605, end: 45609 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + ' PUSHREF // Pure Fift: "" turns it into a cell at compile time' + ] + }, + loc: { start: 45584, end: 45711 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptySlice', + loc: { start: 46077, end: 46087 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 46091, end: 46096 } }, + loc: { start: 46091, end: 46096 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'b{} PUSHSLICE' ] + }, + loc: { start: 46069, end: 46118 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 46431, end: 46439 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'cells', + loc: { start: 46516, end: 46521 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46523, end: 46526 } + }, + loc: { start: 46523, end: 46526 } + }, + initializer: undefined, + loc: { start: 46516, end: 46526 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bits', + loc: { start: 46615, end: 46619 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46621, end: 46624 } + }, + loc: { start: 46621, end: 46624 } + }, + initializer: undefined, + loc: { start: 46615, end: 46624 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'refs', + loc: { start: 46713, end: 46717 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46719, end: 46722 } + }, + loc: { start: 46719, end: 46722 } + }, + initializer: undefined, + loc: { start: 46713, end: 46722 } + } + ], + loc: { start: 46424, end: 46725 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 48450, end: 48465 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 48495, end: 48503 } + }, + typeArgs: [], + loc: { start: 48495, end: 48503 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 48479, end: 48487 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48479, end: 48492 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDATASIZE' ] + }, + loc: { start: 48434, end: 48517 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 48476, end: 48477 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 48472, end: 48476 } + }, + loc: { start: 48472, end: 48476 } + } + ], + loc: { start: 48476, end: 48477 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 50094, end: 50109 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 50139, end: 50147 } + }, + typeArgs: [], + loc: { start: 50139, end: 50147 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 50123, end: 50131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50123, end: 50136 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDATASIZE' ] + }, + loc: { start: 50078, end: 50161 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 50116, end: 50121 } }, + loc: { start: 50116, end: 50121 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 50672, end: 50677 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50692, end: 50695 } + }, + loc: { start: 50692, end: 50695 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDEPTH' ] + }, + loc: { start: 50656, end: 50706 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 50688, end: 50689 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 50684, end: 50688 } + }, + loc: { start: 50684, end: 50688 } + } + ], + loc: { start: 50688, end: 50689 } + } + } + ] + }, + 'checkSignature' => { + kind: 'tact', + path: 'std/internal/crypto.tact', + code: '/// Extension function for the `Cell` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Cell` representation][std-representation] of the given `Cell`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let c: Cell = emptyCell();\n' + + '/// let fizz: Int = c.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#cellhash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Cell): Int { HASHCU }\n' + + '\n' + + '/// Extension function for the `Slice` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Slice` representation][std-representation] of the given `Slice`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().asSlice();\n' + + '/// let fizz: Int = s.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Slice): Int { HASHSU }\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `Slice`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes the data of the given `Slice`, i.e. up to 1023 bits, ignoring the refs.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// // Base64-encoded BoC with "Hello, World!"\n' + + '/// let short: Slice = slice("te6cckEBAQEADgAAGEhlbGxvIHdvcmxkIXgtxbw=");\n' + + '///\n' + + "/// // It's enough to only take the hash of the data\n" + + '/// sha256(short) == short.hashData(); // true\n' + + '///\n' + + '/// // But if we construct a slice larger than 1023 bits with all refs combined,\n' + + "/// // we must use sha256() or we'll get skewed results or even collisions\n" + + '///\n' + + '/// let tmp: Builder = beginCell();\n' + + '/// repeat (127) { tmp = tmp.storeUint(69, 8) } // storing 127 bytes\n' + + '/// let ref: Cell = beginCell().storeUint(33, 8).endCell();\n' + + '/// let long: Slice = tmp.storeRef(ref).asSlice(); // plus a ref with a single byte\n' + + '///\n' + + "/// // Hashing just the data bits in the current slice isn't enough\n" + + '/// sha256(long) == long.hashData(); // false!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `Slice` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: Slice): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Extension function for the `String` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `String`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes up to 127 bytes of the given string. Using longer strings would cause collisions if their first 127 bytes are the same.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let roll: Int = "Never gonna give you up!".hashData(); // just the hash of the data\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `String` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringhashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: String): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the 256-bit unsigned `Int` `hash` using a `publicKey`,\n' + + '/// represented by a 256-bit unsigned `Int`. The signature must contain at least 512 bits of data, but\n' + + '/// only the first 512 bits are used.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// message ExtMsg {\n' + + '/// signature: Slice;\n' + + '/// data: Cell;\n' + + '/// }\n' + + '///\n' + + '/// contract Showcase {\n' + + '/// /// Persistent state variables\n' + + '/// pub: Int as uint256; // public key as a 256-bit unsigned Int\n' + + '///\n' + + '/// /// Constructor function init(), where all variables are initialized\n' + + '/// init(pub: Int) {\n' + + '/// self.pub = pub; // storing the public key upon contract initialization\n' + + '/// }\n' + + '///\n' + + '/// /// External message receiver, which accepts message ExtMsg\n' + + '/// external(msg: ExtMsg) {\n' + + '/// let hash: Int = beginCell().storeRef(msg.data).endCell().hash();\n' + + '/// let check: Bool = checkSignature(hash, msg.signature, self.pub);\n' + + '/// // ---- ------------- --------\n' + + '/// // ↑ ↑ ↑\n' + + '/// // | | publicKey stored in our contract\n' + + '/// // | signature obtained from the received message\n' + + '/// // hash calculated using the data from the received message\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checksignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'asm fun checkSignature(hash: Int, signature: Slice, publicKey: Int): Bool { CHKSIGNU }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the `data` using a `publicKey`, similar to `checkSignature()`.\n' + + '/// Verification itself is done indirectly on a [SHA-256] hash of the `data`.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let data: Slice = someData;\n' + + '/// let signature: Slice = someSignature;\n' + + '/// let publicKey: Int = 42;\n' + + '///\n' + + '/// let check: Bool = checkDataSignature(data, signature, publicKey);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when the bit length of `data` is **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checkdatasignature\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '///\n' + + 'asm fun checkDataSignature(data: Slice, signature: Slice, publicKey: Int): Bool { CHKSIGNS }\n' + + '\n' + + '/// A struct that contains a 512-bit [Ed25519] signature and the data it signs.\n' + + '///\n' + + '/// ```tact\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundle\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'struct SignedBundle {\n' + + ' /// A 512-bit Ed25519 signature of the `signedData`.\n' + + ' signature: Slice as bytes64;\n' + + '\n' + + ' /// The remaining non-serialized data of the enclosing struct or message struct,\n' + + ' /// which was used to obtain the 512-bit Ed25519 `signature`.\n' + + ' signedData: Slice as remaining;\n' + + '}\n' + + '\n' + + '/// Extension function for the `SignedBundle` struct. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Checks whether `self.signedData` was signed by the 512-bit [Ed25519] signature `self.signature`,\n' + + '/// using the given `publicKey`. Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example(publicKey: Int as uint256) {\n' + + '/// external(msg: MessageWithSignedData) {\n' + + '/// // Checks that the signature of the SignedBundle from the incoming external\n' + + "/// // message wasn't forged and made by the owner of this self.publicKey with\n" + + '/// // its respective private key managed elsewhere.\n' + + '/// throwUnless(35, msg.bundle.verifySignature(self.publicKey));\n' + + '///\n' + + '/// // ...rest of the checks and code...\n' + + '/// }\n' + + '/// }\n' + + '///\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'inline extends fun verifySignature(self: SignedBundle, publicKey: Int): Bool {\n' + + ' return checkSignature(self.signedData.hash(), self.signature, publicKey);\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Computes and returns the Ethereum-compatible [Keccak-256] hash as a 256-bit unsigned `Int` from the passed `Slice` `data`.\n' + + '///\n' + + '/// The `data` slice should have a number of bits divisible by 8 and no more than a single reference per cell, because only the first reference of each nested cell will be taken into account.\n' + + '///\n' + + '/// #### Usage\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Examples() {\n' + + '/// receive(rawMsg: Slice) {\n' + + '/// // Hash incoming messa'... 1135 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 554, end: 558 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 572, end: 575 } + }, + loc: { start: 572, end: 575 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHCU' ] + }, + loc: { start: 538, end: 586 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 565, end: 569 } }, + loc: { start: 565, end: 569 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 1232, end: 1236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1251, end: 1254 } + }, + loc: { start: 1251, end: 1254 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHSU' ] + }, + loc: { start: 1216, end: 1265 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1243, end: 1248 } }, + loc: { start: 1243, end: 1248 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 2808, end: 2816 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2831, end: 2834 } + }, + loc: { start: 2831, end: 2834 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 2792, end: 2857 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2823, end: 2828 } }, + loc: { start: 2823, end: 2828 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 3740, end: 3748 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3764, end: 3767 } + }, + loc: { start: 3764, end: 3767 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 3724, end: 3790 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3755, end: 3761 } + }, + typeArgs: [], + loc: { start: 3755, end: 3761 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkSignature', + loc: { start: 5592, end: 5606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 5653, end: 5657 } + }, + typeArgs: [], + loc: { start: 5653, end: 5657 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 5607, end: 5611 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5607, end: 5616 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 5618, end: 5627 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5629, end: 5634 } }, + loc: { start: 5629, end: 5634 } + }, + loc: { start: 5618, end: 5634 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 5636, end: 5645 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5636, end: 5650 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNU' ] + }, + loc: { start: 5584, end: 5670 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkDataSignature', + loc: { start: 6731, end: 6749 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 6798, end: 6802 } + }, + typeArgs: [], + loc: { start: 6798, end: 6802 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 6750, end: 6754 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6756, end: 6761 } }, + loc: { start: 6756, end: 6761 } + }, + loc: { start: 6750, end: 6761 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 6763, end: 6772 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6774, end: 6779 } }, + loc: { start: 6774, end: 6779 } + }, + loc: { start: 6763, end: 6779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 6781, end: 6790 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6781, end: 6795 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNS' ] + }, + loc: { start: 6723, end: 6815 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 7626, end: 7638 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signature', + loc: { start: 7702, end: 7711 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFBits', + bits: 512, + loc: { start: 7713, end: 7729 } + }, + loc: { start: 7713, end: 7718 } + }, + initializer: undefined, + loc: { start: 7702, end: 7729 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signedData', + loc: { start: 7887, end: 7897 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFRemaining', + loc: { start: 7899, end: 7917 } + }, + loc: { start: 7899, end: 7904 } + }, + initializer: undefined, + loc: { start: 7887, end: 7917 } + } + ], + loc: { start: 7619, end: 7920 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'verifySignature', + loc: { start: 9355, end: 9370 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9408, end: 9412 } + }, + typeArgs: [], + loc: { start: 9408, end: 9412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 9391, end: 9400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9391, end: 9405 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'checkSignature', + loc: { start: 9426, end: 9440 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9441, end: 9445 } + }, + field: { + kind: 'id', + text: 'signedData', + loc: { start: 9446, end: 9456 } + }, + loc: { start: 9441, end: 9456 } + }, + method: { + kind: 'id', + text: 'hash', + loc: { start: 9457, end: 9461 } + }, + typeArgs: [], + args: [], + loc: { start: 9441, end: 9463 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9465, end: 9469 } + }, + field: { + kind: 'id', + text: 'signature', + loc: { start: 9470, end: 9479 } + }, + loc: { start: 9465, end: 9479 } + }, + { + kind: 'var', + name: 'publicKey', + loc: { start: 9481, end: 9490 } + } + ], + loc: { start: 9426, end: 9491 } + }, + loc: { start: 9419, end: 9492 } + } + ] + }, + loc: { start: 9336, end: 9494 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 9377, end: 9389 } + }, + typeArgs: [], + loc: { start: 9377, end: 9389 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'keccak256', + loc: { start: 10942, end: 10951 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10966, end: 10969 } + }, + loc: { start: 10966, end: 10969 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 10952, end: 10956 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10952, end: 10963 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' <{ DUP SREFS }> PUSHCONT\n' + + ' <{ LDREFRTOS }> PUSHCONT\n' + + ' WHILE\n' + + ' DEPTH\n' + + ' HASHEXT_KECCAK256\n' + + ' }> PUSHCONT\n' + + ' 1 1 CALLXARGS' + ] + }, + loc: { start: 10934, end: 11134 } + } + ] + }, + 'checkDataSignature' => { + kind: 'tact', + path: 'std/internal/crypto.tact', + code: '/// Extension function for the `Cell` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Cell` representation][std-representation] of the given `Cell`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let c: Cell = emptyCell();\n' + + '/// let fizz: Int = c.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#cellhash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Cell): Int { HASHCU }\n' + + '\n' + + '/// Extension function for the `Slice` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Slice` representation][std-representation] of the given `Slice`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().asSlice();\n' + + '/// let fizz: Int = s.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Slice): Int { HASHSU }\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `Slice`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes the data of the given `Slice`, i.e. up to 1023 bits, ignoring the refs.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// // Base64-encoded BoC with "Hello, World!"\n' + + '/// let short: Slice = slice("te6cckEBAQEADgAAGEhlbGxvIHdvcmxkIXgtxbw=");\n' + + '///\n' + + "/// // It's enough to only take the hash of the data\n" + + '/// sha256(short) == short.hashData(); // true\n' + + '///\n' + + '/// // But if we construct a slice larger than 1023 bits with all refs combined,\n' + + "/// // we must use sha256() or we'll get skewed results or even collisions\n" + + '///\n' + + '/// let tmp: Builder = beginCell();\n' + + '/// repeat (127) { tmp = tmp.storeUint(69, 8) } // storing 127 bytes\n' + + '/// let ref: Cell = beginCell().storeUint(33, 8).endCell();\n' + + '/// let long: Slice = tmp.storeRef(ref).asSlice(); // plus a ref with a single byte\n' + + '///\n' + + "/// // Hashing just the data bits in the current slice isn't enough\n" + + '/// sha256(long) == long.hashData(); // false!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `Slice` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: Slice): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Extension function for the `String` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `String`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes up to 127 bytes of the given string. Using longer strings would cause collisions if their first 127 bytes are the same.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let roll: Int = "Never gonna give you up!".hashData(); // just the hash of the data\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `String` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringhashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: String): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the 256-bit unsigned `Int` `hash` using a `publicKey`,\n' + + '/// represented by a 256-bit unsigned `Int`. The signature must contain at least 512 bits of data, but\n' + + '/// only the first 512 bits are used.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// message ExtMsg {\n' + + '/// signature: Slice;\n' + + '/// data: Cell;\n' + + '/// }\n' + + '///\n' + + '/// contract Showcase {\n' + + '/// /// Persistent state variables\n' + + '/// pub: Int as uint256; // public key as a 256-bit unsigned Int\n' + + '///\n' + + '/// /// Constructor function init(), where all variables are initialized\n' + + '/// init(pub: Int) {\n' + + '/// self.pub = pub; // storing the public key upon contract initialization\n' + + '/// }\n' + + '///\n' + + '/// /// External message receiver, which accepts message ExtMsg\n' + + '/// external(msg: ExtMsg) {\n' + + '/// let hash: Int = beginCell().storeRef(msg.data).endCell().hash();\n' + + '/// let check: Bool = checkSignature(hash, msg.signature, self.pub);\n' + + '/// // ---- ------------- --------\n' + + '/// // ↑ ↑ ↑\n' + + '/// // | | publicKey stored in our contract\n' + + '/// // | signature obtained from the received message\n' + + '/// // hash calculated using the data from the received message\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checksignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'asm fun checkSignature(hash: Int, signature: Slice, publicKey: Int): Bool { CHKSIGNU }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the `data` using a `publicKey`, similar to `checkSignature()`.\n' + + '/// Verification itself is done indirectly on a [SHA-256] hash of the `data`.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let data: Slice = someData;\n' + + '/// let signature: Slice = someSignature;\n' + + '/// let publicKey: Int = 42;\n' + + '///\n' + + '/// let check: Bool = checkDataSignature(data, signature, publicKey);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when the bit length of `data` is **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checkdatasignature\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '///\n' + + 'asm fun checkDataSignature(data: Slice, signature: Slice, publicKey: Int): Bool { CHKSIGNS }\n' + + '\n' + + '/// A struct that contains a 512-bit [Ed25519] signature and the data it signs.\n' + + '///\n' + + '/// ```tact\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundle\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'struct SignedBundle {\n' + + ' /// A 512-bit Ed25519 signature of the `signedData`.\n' + + ' signature: Slice as bytes64;\n' + + '\n' + + ' /// The remaining non-serialized data of the enclosing struct or message struct,\n' + + ' /// which was used to obtain the 512-bit Ed25519 `signature`.\n' + + ' signedData: Slice as remaining;\n' + + '}\n' + + '\n' + + '/// Extension function for the `SignedBundle` struct. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Checks whether `self.signedData` was signed by the 512-bit [Ed25519] signature `self.signature`,\n' + + '/// using the given `publicKey`. Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example(publicKey: Int as uint256) {\n' + + '/// external(msg: MessageWithSignedData) {\n' + + '/// // Checks that the signature of the SignedBundle from the incoming external\n' + + "/// // message wasn't forged and made by the owner of this self.publicKey with\n" + + '/// // its respective private key managed elsewhere.\n' + + '/// throwUnless(35, msg.bundle.verifySignature(self.publicKey));\n' + + '///\n' + + '/// // ...rest of the checks and code...\n' + + '/// }\n' + + '/// }\n' + + '///\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'inline extends fun verifySignature(self: SignedBundle, publicKey: Int): Bool {\n' + + ' return checkSignature(self.signedData.hash(), self.signature, publicKey);\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Computes and returns the Ethereum-compatible [Keccak-256] hash as a 256-bit unsigned `Int` from the passed `Slice` `data`.\n' + + '///\n' + + '/// The `data` slice should have a number of bits divisible by 8 and no more than a single reference per cell, because only the first reference of each nested cell will be taken into account.\n' + + '///\n' + + '/// #### Usage\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Examples() {\n' + + '/// receive(rawMsg: Slice) {\n' + + '/// // Hash incoming messa'... 1135 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 554, end: 558 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 572, end: 575 } + }, + loc: { start: 572, end: 575 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHCU' ] + }, + loc: { start: 538, end: 586 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 565, end: 569 } }, + loc: { start: 565, end: 569 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 1232, end: 1236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1251, end: 1254 } + }, + loc: { start: 1251, end: 1254 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHSU' ] + }, + loc: { start: 1216, end: 1265 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1243, end: 1248 } }, + loc: { start: 1243, end: 1248 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 2808, end: 2816 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2831, end: 2834 } + }, + loc: { start: 2831, end: 2834 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 2792, end: 2857 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2823, end: 2828 } }, + loc: { start: 2823, end: 2828 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 3740, end: 3748 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3764, end: 3767 } + }, + loc: { start: 3764, end: 3767 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 3724, end: 3790 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3755, end: 3761 } + }, + typeArgs: [], + loc: { start: 3755, end: 3761 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkSignature', + loc: { start: 5592, end: 5606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 5653, end: 5657 } + }, + typeArgs: [], + loc: { start: 5653, end: 5657 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 5607, end: 5611 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5607, end: 5616 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 5618, end: 5627 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5629, end: 5634 } }, + loc: { start: 5629, end: 5634 } + }, + loc: { start: 5618, end: 5634 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 5636, end: 5645 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5636, end: 5650 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNU' ] + }, + loc: { start: 5584, end: 5670 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkDataSignature', + loc: { start: 6731, end: 6749 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 6798, end: 6802 } + }, + typeArgs: [], + loc: { start: 6798, end: 6802 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 6750, end: 6754 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6756, end: 6761 } }, + loc: { start: 6756, end: 6761 } + }, + loc: { start: 6750, end: 6761 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 6763, end: 6772 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6774, end: 6779 } }, + loc: { start: 6774, end: 6779 } + }, + loc: { start: 6763, end: 6779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 6781, end: 6790 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6781, end: 6795 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNS' ] + }, + loc: { start: 6723, end: 6815 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 7626, end: 7638 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signature', + loc: { start: 7702, end: 7711 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFBits', + bits: 512, + loc: { start: 7713, end: 7729 } + }, + loc: { start: 7713, end: 7718 } + }, + initializer: undefined, + loc: { start: 7702, end: 7729 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signedData', + loc: { start: 7887, end: 7897 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFRemaining', + loc: { start: 7899, end: 7917 } + }, + loc: { start: 7899, end: 7904 } + }, + initializer: undefined, + loc: { start: 7887, end: 7917 } + } + ], + loc: { start: 7619, end: 7920 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'verifySignature', + loc: { start: 9355, end: 9370 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9408, end: 9412 } + }, + typeArgs: [], + loc: { start: 9408, end: 9412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 9391, end: 9400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9391, end: 9405 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'checkSignature', + loc: { start: 9426, end: 9440 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9441, end: 9445 } + }, + field: { + kind: 'id', + text: 'signedData', + loc: { start: 9446, end: 9456 } + }, + loc: { start: 9441, end: 9456 } + }, + method: { + kind: 'id', + text: 'hash', + loc: { start: 9457, end: 9461 } + }, + typeArgs: [], + args: [], + loc: { start: 9441, end: 9463 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9465, end: 9469 } + }, + field: { + kind: 'id', + text: 'signature', + loc: { start: 9470, end: 9479 } + }, + loc: { start: 9465, end: 9479 } + }, + { + kind: 'var', + name: 'publicKey', + loc: { start: 9481, end: 9490 } + } + ], + loc: { start: 9426, end: 9491 } + }, + loc: { start: 9419, end: 9492 } + } + ] + }, + loc: { start: 9336, end: 9494 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 9377, end: 9389 } + }, + typeArgs: [], + loc: { start: 9377, end: 9389 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'keccak256', + loc: { start: 10942, end: 10951 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10966, end: 10969 } + }, + loc: { start: 10966, end: 10969 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 10952, end: 10956 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10952, end: 10963 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' <{ DUP SREFS }> PUSHCONT\n' + + ' <{ LDREFRTOS }> PUSHCONT\n' + + ' WHILE\n' + + ' DEPTH\n' + + ' HASHEXT_KECCAK256\n' + + ' }> PUSHCONT\n' + + ' 1 1 CALLXARGS' + ] + }, + loc: { start: 10934, end: 11134 } + } + ] + }, + 'keccak256' => { + kind: 'tact', + path: 'std/internal/crypto.tact', + code: '/// Extension function for the `Cell` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Cell` representation][std-representation] of the given `Cell`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let c: Cell = emptyCell();\n' + + '/// let fizz: Int = c.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#cellhash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Cell): Int { HASHCU }\n' + + '\n' + + '/// Extension function for the `Slice` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Slice` representation][std-representation] of the given `Slice`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().asSlice();\n' + + '/// let fizz: Int = s.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Slice): Int { HASHSU }\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `Slice`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes the data of the given `Slice`, i.e. up to 1023 bits, ignoring the refs.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// // Base64-encoded BoC with "Hello, World!"\n' + + '/// let short: Slice = slice("te6cckEBAQEADgAAGEhlbGxvIHdvcmxkIXgtxbw=");\n' + + '///\n' + + "/// // It's enough to only take the hash of the data\n" + + '/// sha256(short) == short.hashData(); // true\n' + + '///\n' + + '/// // But if we construct a slice larger than 1023 bits with all refs combined,\n' + + "/// // we must use sha256() or we'll get skewed results or even collisions\n" + + '///\n' + + '/// let tmp: Builder = beginCell();\n' + + '/// repeat (127) { tmp = tmp.storeUint(69, 8) } // storing 127 bytes\n' + + '/// let ref: Cell = beginCell().storeUint(33, 8).endCell();\n' + + '/// let long: Slice = tmp.storeRef(ref).asSlice(); // plus a ref with a single byte\n' + + '///\n' + + "/// // Hashing just the data bits in the current slice isn't enough\n" + + '/// sha256(long) == long.hashData(); // false!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `Slice` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: Slice): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Extension function for the `String` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `String`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes up to 127 bytes of the given string. Using longer strings would cause collisions if their first 127 bytes are the same.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let roll: Int = "Never gonna give you up!".hashData(); // just the hash of the data\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `String` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringhashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: String): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the 256-bit unsigned `Int` `hash` using a `publicKey`,\n' + + '/// represented by a 256-bit unsigned `Int`. The signature must contain at least 512 bits of data, but\n' + + '/// only the first 512 bits are used.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// message ExtMsg {\n' + + '/// signature: Slice;\n' + + '/// data: Cell;\n' + + '/// }\n' + + '///\n' + + '/// contract Showcase {\n' + + '/// /// Persistent state variables\n' + + '/// pub: Int as uint256; // public key as a 256-bit unsigned Int\n' + + '///\n' + + '/// /// Constructor function init(), where all variables are initialized\n' + + '/// init(pub: Int) {\n' + + '/// self.pub = pub; // storing the public key upon contract initialization\n' + + '/// }\n' + + '///\n' + + '/// /// External message receiver, which accepts message ExtMsg\n' + + '/// external(msg: ExtMsg) {\n' + + '/// let hash: Int = beginCell().storeRef(msg.data).endCell().hash();\n' + + '/// let check: Bool = checkSignature(hash, msg.signature, self.pub);\n' + + '/// // ---- ------------- --------\n' + + '/// // ↑ ↑ ↑\n' + + '/// // | | publicKey stored in our contract\n' + + '/// // | signature obtained from the received message\n' + + '/// // hash calculated using the data from the received message\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checksignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'asm fun checkSignature(hash: Int, signature: Slice, publicKey: Int): Bool { CHKSIGNU }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the `data` using a `publicKey`, similar to `checkSignature()`.\n' + + '/// Verification itself is done indirectly on a [SHA-256] hash of the `data`.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let data: Slice = someData;\n' + + '/// let signature: Slice = someSignature;\n' + + '/// let publicKey: Int = 42;\n' + + '///\n' + + '/// let check: Bool = checkDataSignature(data, signature, publicKey);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when the bit length of `data` is **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checkdatasignature\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '///\n' + + 'asm fun checkDataSignature(data: Slice, signature: Slice, publicKey: Int): Bool { CHKSIGNS }\n' + + '\n' + + '/// A struct that contains a 512-bit [Ed25519] signature and the data it signs.\n' + + '///\n' + + '/// ```tact\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundle\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'struct SignedBundle {\n' + + ' /// A 512-bit Ed25519 signature of the `signedData`.\n' + + ' signature: Slice as bytes64;\n' + + '\n' + + ' /// The remaining non-serialized data of the enclosing struct or message struct,\n' + + ' /// which was used to obtain the 512-bit Ed25519 `signature`.\n' + + ' signedData: Slice as remaining;\n' + + '}\n' + + '\n' + + '/// Extension function for the `SignedBundle` struct. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Checks whether `self.signedData` was signed by the 512-bit [Ed25519] signature `self.signature`,\n' + + '/// using the given `publicKey`. Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example(publicKey: Int as uint256) {\n' + + '/// external(msg: MessageWithSignedData) {\n' + + '/// // Checks that the signature of the SignedBundle from the incoming external\n' + + "/// // message wasn't forged and made by the owner of this self.publicKey with\n" + + '/// // its respective private key managed elsewhere.\n' + + '/// throwUnless(35, msg.bundle.verifySignature(self.publicKey));\n' + + '///\n' + + '/// // ...rest of the checks and code...\n' + + '/// }\n' + + '/// }\n' + + '///\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'inline extends fun verifySignature(self: SignedBundle, publicKey: Int): Bool {\n' + + ' return checkSignature(self.signedData.hash(), self.signature, publicKey);\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Computes and returns the Ethereum-compatible [Keccak-256] hash as a 256-bit unsigned `Int` from the passed `Slice` `data`.\n' + + '///\n' + + '/// The `data` slice should have a number of bits divisible by 8 and no more than a single reference per cell, because only the first reference of each nested cell will be taken into account.\n' + + '///\n' + + '/// #### Usage\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Examples() {\n' + + '/// receive(rawMsg: Slice) {\n' + + '/// // Hash incoming messa'... 1135 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 554, end: 558 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 572, end: 575 } + }, + loc: { start: 572, end: 575 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHCU' ] + }, + loc: { start: 538, end: 586 } + } + }, + selfType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 565, end: 569 } }, + loc: { start: 565, end: 569 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 1232, end: 1236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1251, end: 1254 } + }, + loc: { start: 1251, end: 1254 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHSU' ] + }, + loc: { start: 1216, end: 1265 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1243, end: 1248 } }, + loc: { start: 1243, end: 1248 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 2808, end: 2816 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2831, end: 2834 } + }, + loc: { start: 2831, end: 2834 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 2792, end: 2857 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2823, end: 2828 } }, + loc: { start: 2823, end: 2828 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 3740, end: 3748 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3764, end: 3767 } + }, + loc: { start: 3764, end: 3767 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 3724, end: 3790 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3755, end: 3761 } + }, + typeArgs: [], + loc: { start: 3755, end: 3761 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkSignature', + loc: { start: 5592, end: 5606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 5653, end: 5657 } + }, + typeArgs: [], + loc: { start: 5653, end: 5657 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 5607, end: 5611 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5607, end: 5616 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 5618, end: 5627 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5629, end: 5634 } }, + loc: { start: 5629, end: 5634 } + }, + loc: { start: 5618, end: 5634 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 5636, end: 5645 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5636, end: 5650 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNU' ] + }, + loc: { start: 5584, end: 5670 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkDataSignature', + loc: { start: 6731, end: 6749 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 6798, end: 6802 } + }, + typeArgs: [], + loc: { start: 6798, end: 6802 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 6750, end: 6754 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6756, end: 6761 } }, + loc: { start: 6756, end: 6761 } + }, + loc: { start: 6750, end: 6761 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 6763, end: 6772 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6774, end: 6779 } }, + loc: { start: 6774, end: 6779 } + }, + loc: { start: 6763, end: 6779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 6781, end: 6790 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6781, end: 6795 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNS' ] + }, + loc: { start: 6723, end: 6815 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 7626, end: 7638 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signature', + loc: { start: 7702, end: 7711 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFBits', + bits: 512, + loc: { start: 7713, end: 7729 } + }, + loc: { start: 7713, end: 7718 } + }, + initializer: undefined, + loc: { start: 7702, end: 7729 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signedData', + loc: { start: 7887, end: 7897 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFRemaining', + loc: { start: 7899, end: 7917 } + }, + loc: { start: 7899, end: 7904 } + }, + initializer: undefined, + loc: { start: 7887, end: 7917 } + } + ], + loc: { start: 7619, end: 7920 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'verifySignature', + loc: { start: 9355, end: 9370 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9408, end: 9412 } + }, + typeArgs: [], + loc: { start: 9408, end: 9412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 9391, end: 9400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9391, end: 9405 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'checkSignature', + loc: { start: 9426, end: 9440 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9441, end: 9445 } + }, + field: { + kind: 'id', + text: 'signedData', + loc: { start: 9446, end: 9456 } + }, + loc: { start: 9441, end: 9456 } + }, + method: { + kind: 'id', + text: 'hash', + loc: { start: 9457, end: 9461 } + }, + typeArgs: [], + args: [], + loc: { start: 9441, end: 9463 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9465, end: 9469 } + }, + field: { + kind: 'id', + text: 'signature', + loc: { start: 9470, end: 9479 } + }, + loc: { start: 9465, end: 9479 } + }, + { + kind: 'var', + name: 'publicKey', + loc: { start: 9481, end: 9490 } + } + ], + loc: { start: 9426, end: 9491 } + }, + loc: { start: 9419, end: 9492 } + } + ] + }, + loc: { start: 9336, end: 9494 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 9377, end: 9389 } + }, + typeArgs: [], + loc: { start: 9377, end: 9389 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'keccak256', + loc: { start: 10942, end: 10951 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10966, end: 10969 } + }, + loc: { start: 10966, end: 10969 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 10952, end: 10956 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10952, end: 10963 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' <{ DUP SREFS }> PUSHCONT\n' + + ' <{ LDREFRTOS }> PUSHCONT\n' + + ' WHILE\n' + + ' DEPTH\n' + + ' HASHEXT_KECCAK256\n' + + ' }> PUSHCONT\n' + + ' 1 1 CALLXARGS' + ] + }, + loc: { start: 10934, end: 11134 } + } + ] + }, + 'beginString' => { + kind: 'tact', + path: 'std/internal/text.tact', + code: '//\n' + + '// String builder\n' + + '//\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstring\n' + + '///\n' + + '@name(__tact_string_builder_start_string)\n' + + 'native beginString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a comment string, which prefixes\n' + + '/// the resulting `String` with four null bytes. This format is used for passing text comments\n' + + '/// as message bodies.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginComment();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begincomment\n' + + '///\n' + + '@name(__tact_string_builder_start_comment)\n' + + 'native beginComment(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a tail string, which prefixes\n' + + '/// the resulting `String` with a single null byte. This format is used in various standards\n' + + '/// such as NFT or Jetton.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginTailString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begintailstring\n' + + '///\n' + + '@name(__tact_string_builder_start_tail_string)\n' + + 'native beginTailString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns a new `StringBuilder` from an existing `StringBuilder` `b`. Useful when\n' + + '/// you need to serialize an existing `String` to a `Cell` along with other data.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginStringFromBuilder(beginString());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstringfrombuilder\n' + + '///\n' + + '@name(__tact_string_builder_start)\n' + + 'native beginStringFromBuilder(b: Builder): StringBuilder;\n' + + '\n' + + '/// Extension mutation function for the `StringBuilder` type.\n' + + '///\n' + + '/// Appends a `String` `s` to the `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// fizz.append("oh");\n' + + '/// fizz.append("my");\n' + + '/// fizz.append("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderappend\n' + + '///\n' + + '@name(__tact_string_builder_append)\n' + + 'extends mutates native append(self: StringBuilder, s: String);\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a new `StringBuilder` after concatenating it with a `String` `s`. It can be chained,\n' + + '/// unlike `StringBuilder.append()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString()\n' + + '/// .concat("oh")\n' + + '/// .concat("my")\n' + + '/// .concat("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderconcat\n' + + '///\n' + + '@name(__tact_string_builder_append_not_mut)\n' + + 'extends native concat(self: StringBuilder, s: String): StringBuilder;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: Cell = fizz.toCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertocell\n' + + '///\n' + + '@name(__tact_string_builder_end)\n' + + 'extends native toCell(self: StringBuilder): Cell;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a built `String` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: String = fizz.toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertostring\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toString(self: StringBuilder): String;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` as a `Slice` from a `StringBuilder`.\n' + + '/// An alias to `self.toCell().asSlice()`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StringBuilder = beginString();\n' + + '/// let fizz: Slice = s.toSlice();\n' + + '/// let buzz: Slice = s.toCell().asSlice();\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertoslice\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toSlice(self: StringBuilder): Slice;\n' + + '\n' + + '//\n' + + '// String conversion\n' + + '//\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (84 - 42).toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttostring\n' + + '///\n' + + 'asm extends fun toString(self: Int): String {\n' + + ' // x\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representation] of a fractional\n' + + '/// number, where `self` is the significant part of the number and `digits` is the number\n' + + '/// of digits in the fractional part.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (42).toFloatString(9); // "0.000000042"\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 134: [Invalid argument] — Thrown when the given `digits` value is out of range.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttofloatstring\n' + + '///\n' + + '/// [fixed-point representation]: https://en.wikipedia.org/wiki/Fixed-point_arithmetic\n' + + '/// [Invalid argument]: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'asm extends fun toFloatString(self: Int, digits: Int): String {\n' + + ' // x digits\n' + + '\n' + + ' DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representatio'... 6219 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginString', + loc: { start: 329, end: 340 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 344, end: 357 } + }, + typeArgs: [], + loc: { start: 344, end: 357 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_string', + loc: { start: 286, end: 320 } + } + }, + loc: { start: 280, end: 358 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginComment', + loc: { start: 830, end: 842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 846, end: 859 } + }, + typeArgs: [], + loc: { start: 846, end: 859 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_comment', + loc: { start: 786, end: 821 } + } + }, + loc: { start: 780, end: 860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginTailString', + loc: { start: 1341, end: 1356 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1360, end: 1373 } + }, + typeArgs: [], + loc: { start: 1360, end: 1373 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_tail_string', + loc: { start: 1293, end: 1332 } + } + }, + loc: { start: 1287, end: 1374 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginStringFromBuilder', + loc: { start: 1836, end: 1858 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1872, end: 1885 } + }, + typeArgs: [], + loc: { start: 1872, end: 1885 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'b', + loc: { start: 1859, end: 1860 } + }, + type: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1862, end: 1869 } }, + loc: { start: 1862, end: 1869 } + }, + loc: { start: 1859, end: 1869 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start', + loc: { start: 1800, end: 1827 } + } + }, + loc: { start: 1794, end: 1886 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'append', + loc: { start: 2328, end: 2334 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2356, end: 2357 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2359, end: 2365 } + }, + typeArgs: [], + loc: { start: 2359, end: 2365 } + }, + loc: { start: 2356, end: 2365 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append', + loc: { start: 2275, end: 2303 } + } + }, + loc: { start: 2269, end: 2367 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2341, end: 2354 } + }, + typeArgs: [], + loc: { start: 2341, end: 2354 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'concat', + loc: { start: 2880, end: 2886 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2920, end: 2933 } + }, + typeArgs: [], + loc: { start: 2920, end: 2933 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2908, end: 2909 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2911, end: 2917 } + }, + typeArgs: [], + loc: { start: 2911, end: 2917 } + }, + loc: { start: 2908, end: 2917 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append_not_mut', + loc: { start: 2827, end: 2863 } + } + }, + loc: { start: 2821, end: 2934 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2893, end: 2906 } + }, + typeArgs: [], + loc: { start: 2893, end: 2906 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toCell', + loc: { start: 3392, end: 3398 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3421, end: 3425 } }, + loc: { start: 3421, end: 3425 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end', + loc: { start: 3350, end: 3375 } + } + }, + loc: { start: 3344, end: 3426 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3405, end: 3418 } + }, + typeArgs: [], + loc: { start: 3405, end: 3418 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 3893, end: 3901 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3924, end: 3930 } + }, + typeArgs: [], + loc: { start: 3924, end: 3930 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 3845, end: 3876 } + } + }, + loc: { start: 3839, end: 3931 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3908, end: 3921 } + }, + typeArgs: [], + loc: { start: 3908, end: 3921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toSlice', + loc: { start: 4530, end: 4537 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 4560, end: 4565 } }, + loc: { start: 4560, end: 4565 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 4482, end: 4513 } + } + }, + loc: { start: 4476, end: 4566 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 4544, end: 4557 } + }, + typeArgs: [], + loc: { start: 4544, end: 4557 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 4950, end: 4958 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 4971, end: 4977 } + }, + typeArgs: [], + loc: { start: 4971, end: 4977 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 4934, end: 5692 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4965, end: 4968 } + }, + loc: { start: 4965, end: 4968 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toFloatString', + loc: { start: 6527, end: 6540 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 6566, end: 6572 } + }, + typeArgs: [], + loc: { start: 6566, end: 6572 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'digits', + loc: { start: 6552, end: 6558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6552, end: 6563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 6511, end: 9874 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6547, end: 6550 } + }, + loc: { start: 6547, end: 6550 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'toCoinsString', + loc: { start: 10653, end: 10666 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 10679, end: 10685 } + }, + typeArgs: [], + loc: { start: 10679, end: 10685 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 10699, end: 10703 } + }, + method: { + kind: 'id', + text: 'toFloatString', + loc: { start: 10704, end: 10717 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 9n, + loc: { start: 10718, end: 10719 } + } + ], + loc: { start: 10699, end: 10720 } + }, + loc: { start: 10692, end: 10721 } + } + ] + }, + loc: { start: 10634, end: 10723 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10673, end: 10676 } + }, + loc: { start: 10673, end: 10676 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asComment', + loc: { start: 11442, end: 11451 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 11467, end: 11471 } + }, + loc: { start: 11467, end: 11471 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'b', + loc: { start: 11482, end: 11483 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 11485, end: 11498 } + }, + typeArgs: [], + loc: { start: 11485, end: 11498 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginComment', + loc: { start: 11501, end: 11513 } + }, + typeArgs: [], + args: [], + loc: { start: 11501, end: 11515 } + }, + loc: { start: 11478, end: 11516 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11521, end: 11522 } + }, + method: { + kind: 'id', + text: 'append', + loc: { start: 11523, end: 11529 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 11530, end: 11534 } + } + ], + loc: { start: 11521, end: 11535 } + }, + loc: { start: 11521, end: 11536 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11548, end: 11549 } + }, + method: { + kind: 'id', + text: 'toCell', + loc: { start: 11550, end: 11556 } + }, + typeArgs: [], + args: [], + loc: { start: 11548, end: 11558 } + }, + loc: { start: 11541, end: 11559 } + } + ] + }, + loc: { start: 11430, end: 11561 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 11458, end: 11464 } + }, + typeArgs: [], + loc: { start: 11458, end: 11464 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 12075, end: 12082 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 12098, end: 12103 } + }, + loc: { start: 12098, end: 12103 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_str_to_slice', + loc: { start: 12039, end: 12058 } + } + }, + loc: { start: 12033, end: 12104 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12089, end: 12095 } + }, + typeArgs: [], + loc: { start: 12089, end: 12095 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asString', + loc: { start: 12598, end: 12606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12621, end: 12627 } + }, + typeArgs: [], + loc: { start: 12621, end: 12627 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_slice_to_str', + loc: { start: 12562, end: 12581 } + } + }, + loc: { start: 12556, end: 12628 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 12613, end: 12618 } }, + loc: { start: 12613, end: 12618 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13537, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 13563, end: 13568 } + }, + loc: { start: 13563, end: 13568 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 13582, end: 13586 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 13587, end: 13594 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13596 } + }, + method: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13597, end: 13607 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13609 } + }, + loc: { start: 13575, end: 13610 } + } + ] + }, + loc: { start: 13518, end: 13612 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 13554, end: 13560 } + }, + typeArgs: [], + loc: { start: 13554, end: 13560 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 14642, end: 14652 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 14667, end: 14672 } + }, + loc: { start: 14667, end: 14672 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'size', + loc: { start: 14683, end: 14687 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14689, end: 14692 } + }, + loc: { start: 14689, end: 14692 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14695, end: 14699 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 14700, end: 14704 } + }, + typeArgs: [], + args: [], + loc: { start: 14695, end: 14706 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14709, end: 14710 } + }, + loc: { start: 14695, end: 14710 } + }, + loc: { start: 14679, end: 14711 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 14720, end: 14726 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 14728, end: 14735 } + }, + loc: { start: 14728, end: 14735 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 14738, end: 14747 } + }, + typeArgs: [], + args: [], + loc: { start: 14738, end: 14749 } + }, + loc: { start: 14716, end: 14750 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'size', + loc: { start: 14764, end: 14768 } + }, + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'code', + loc: { start: 14784, end: 14788 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14790, end: 14793 } + }, + loc: { start: 14790, end: 14793 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14796, end: 14800 } + }, + method: { + kind: 'id', + text: 'loadUint', + loc: { start: 14801, end: 14809 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14810, end: 14811 } + } + ], + loc: { start: 14796, end: 14812 } + }, + loc: { start: 14780, end: 14813 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14826, end: 14830 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14834, end: 14836 } + }, + loc: { start: 14826, end: 14836 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14840, end: 14844 } + }, + right: { + kind: 'number', + base: '10', + value: 90n, + loc: { start: 14848, end: 14850 } + }, + loc: { start: 14840, end: 14850 } + }, + loc: { start: 14826, end: 14850 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14873, end: 14879 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14882, end: 14888 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14889, end: 14898 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 14899, end: 14903 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14906, end: 14908 } + }, + loc: { start: 14899, end: 14908 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 14910, end: 14911 } + } + ], + loc: { start: 14882, end: 14912 } + }, + loc: { start: 14873, end: 14913 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14933, end: 14937 } + }, + right: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 14941, end: 14943 } + }, + loc: { start: 14933, end: 14943 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14947, end: 14951 } + }, + right: { + kind: 'number', + base: '10', + value: 122n, + loc: { start: 14955, end: 14958 } + }, + loc: { start: 14947, end: 14958 } + }, + loc: { start: 14933, end: 14958 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14981, end: 14987 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14990, end: 14996 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14997, end: 15006 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 15007, end: 15011 } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 15015, end: 15017 } + }, + right: { + kind: 'number', + base: '10', + value: 26n, + loc: { start: 15020, end: 15022 } + }, + loc: { start: 15015, end: 15022 } + }, + loc: { start: 15007, end: 15023 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15025, end: 15026 } + } + ], + loc: { start: 14990, end: 15027 } + }, + loc: { start: 14981, end: 15028 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15048, end: 15052 } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { start: 15056, end: 15058 } + }, + loc: { start: 15048, end: 15058 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15062, end: 15066 } + }, + right: { + kind: 'number', + base: '10', + value: 57n, + loc: { start: 15070, end: 15072 } + }, + loc: { start: 15062, end: 15072 } + }, + loc: { start: 15048, end: 15072 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15095, end: 15101 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15104, end: 15110 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 15111, end: 15120 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15121, + end: 15125 + } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 52n, + loc: { + start: 15129, + end: 15131 + } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { + start: 15134, + end: 15136 + } + }, + loc: { + start: 15129, + end: 15136 + } + }, + loc: { start: 15121, end: 15137 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15139, end: 15140 } + } + ], + loc: { start: 15104, end: 15141 } + }, + loc: { start: 15095, end: 15142 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15162, end: 15166 } + }, + right: { + kind: 'number', + base: '10', + value: 45n, + loc: { start: 15170, end: 15172 } + }, + loc: { start: 15162, end: 15172 } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15176, end: 15180 } + }, + right: { + kind: 'number', + base: '10', + value: 43n, + loc: { start: 15184, end: 15186 } + }, + loc: { start: 15176, end: 15186 } + }, + loc: { start: 15162, end: 15186 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15212, end: 15218 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15221, + end: 15227 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15228, + end: 15237 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 62n, + loc: { + start: 15238, + end: 15240 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15242, + end: 15243 + } + } + ], + loc: { start: 15221, end: 15244 } + }, + loc: { start: 15212, end: 15245 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15265, + end: 15269 + } + }, + right: { + kind: 'number', + base: '10', + value: 95n, + loc: { + start: 15273, + end: 15275 + } + }, + loc: { + start: 15265, + end: 15275 + } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15279, + end: 15283 + } + }, + right: { + kind: 'number', + base: '10', + value: 47n, + loc: { + start: 15287, + end: 15289 + } + }, + loc: { + start: 15279, + end: 15289 + } + }, + loc: { start: 15265, end: 15289 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 15315, + end: 15321 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15324, + end: 15330 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15331, + end: 15340 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 63n, + loc: { + start: 15341, + end: 15343 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15345, + end: 15346 + } + } + ], + loc: { + start: 15324, + end: 15347 + } + }, + loc: { + start: 15315, + end: 15348 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15368, + end: 15372 + } + }, + right: { + kind: 'number', + base: '10', + value: 61n, + loc: { + start: 15376, + end: 15378 + } + }, + loc: { + start: 15368, + end: 15378 + } + }, + trueStatements: [], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throw', + loc: { + start: 15436, + end: 15441 + } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidArgument', + loc: { + start: 15442, + end: 15469 + } + } + ], + loc: { + start: 15436, + end: 15470 + } + }, + loc: { + start: 15436, + end: 15471 + } + } + ], + loc: { + start: 15364, + end: 15481 + } + } + ], + loc: { start: 15261, end: 15481 } + } + ], + loc: { start: 15158, end: 15481 } + } + ], + loc: { start: 15044, end: 15481 } + } + ], + loc: { start: 14929, end: 15481 } + } + ], + loc: { start: 14822, end: 15481 } + } + ], + loc: { start: 14756, end: 15487 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'total', + loc: { start: 15512, end: 15517 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15519, end: 15522 } + }, + loc: { start: 15519, end: 15522 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15525, end: 15531 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 15532, end: 15536 } + }, + typeArgs: [], + args: [], + loc: { start: 15525, end: 15538 } + }, + loc: { start: 15508, end: 15539 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'padding', + loc: { start: 15548, end: 15555 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15557, end: 15560 } + }, + loc: { start: 15557, end: 15560 } + }, + expression: { + kind: 'op_binary', + op: '%', + left: { + kind: 'var', + name: 'total', + loc: { start: 15563, end: 15568 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 15571, end: 15572 } + }, + loc: { start: 15563, end: 15572 } + }, + loc: { start: 15544, end: 15573 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '!=', + left: { + kind: 'var', + name: 'padding', + loc: { start: 15582, end: 15589 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15593, end: 15594 } + }, + loc: { start: 15582, end: 15594 } + }, + trueStatements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15610, end: 15611 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 15613, end: 15618 } + }, + loc: { start: 15613, end: 15618 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15621, end: 15627 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15628, end: 15635 } + }, + typeArgs: [], + args: [], + loc: { start: 15621, end: 15637 } + }, + loc: { start: 15606, end: 15638 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 's', + loc: { start: 15654, end: 15655 } + }, + method: { + kind: 'id', + text: 'loadBits', + loc: { start: 15656, end: 15664 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'total', + loc: { start: 15665, end: 15670 } + }, + right: { + kind: 'var', + name: 'padding', + loc: { start: 15673, end: 15680 } + }, + loc: { start: 15665, end: 15680 } + } + ], + loc: { start: 15654, end: 15681 } + }, + loc: { start: 15647, end: 15682 } + } + ], + falseStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15711, end: 15717 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15718, end: 15725 } + }, + typeArgs: [], + args: [], + loc: { start: 15711, end: 15727 } + }, + loc: { start: 15704, end: 15728 } + } + ], + loc: { start: 15578, end: 15734 } + } + ] + }, + loc: { start: 14630, end: 15736 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 14659, end: 14664 } }, + loc: { start: 14659, end: 14664 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 16186, end: 16194 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 16211, end: 16217 } + }, + typeArgs: [], + loc: { start: 16211, end: 16217 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_address_to_user_friendly', + loc: { start: 16138, end: 16169 } + } + }, + loc: { start: 16132, end: 16218 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 16201, end: 16208 } + }, + typeArgs: [], + loc: { start: 16201, end: 16208 } + } + } + ] + }, + 'beginComment' => { + kind: 'tact', + path: 'std/internal/text.tact', + code: '//\n' + + '// String builder\n' + + '//\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstring\n' + + '///\n' + + '@name(__tact_string_builder_start_string)\n' + + 'native beginString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a comment string, which prefixes\n' + + '/// the resulting `String` with four null bytes. This format is used for passing text comments\n' + + '/// as message bodies.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginComment();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begincomment\n' + + '///\n' + + '@name(__tact_string_builder_start_comment)\n' + + 'native beginComment(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a tail string, which prefixes\n' + + '/// the resulting `String` with a single null byte. This format is used in various standards\n' + + '/// such as NFT or Jetton.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginTailString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begintailstring\n' + + '///\n' + + '@name(__tact_string_builder_start_tail_string)\n' + + 'native beginTailString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns a new `StringBuilder` from an existing `StringBuilder` `b`. Useful when\n' + + '/// you need to serialize an existing `String` to a `Cell` along with other data.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginStringFromBuilder(beginString());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstringfrombuilder\n' + + '///\n' + + '@name(__tact_string_builder_start)\n' + + 'native beginStringFromBuilder(b: Builder): StringBuilder;\n' + + '\n' + + '/// Extension mutation function for the `StringBuilder` type.\n' + + '///\n' + + '/// Appends a `String` `s` to the `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// fizz.append("oh");\n' + + '/// fizz.append("my");\n' + + '/// fizz.append("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderappend\n' + + '///\n' + + '@name(__tact_string_builder_append)\n' + + 'extends mutates native append(self: StringBuilder, s: String);\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a new `StringBuilder` after concatenating it with a `String` `s`. It can be chained,\n' + + '/// unlike `StringBuilder.append()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString()\n' + + '/// .concat("oh")\n' + + '/// .concat("my")\n' + + '/// .concat("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderconcat\n' + + '///\n' + + '@name(__tact_string_builder_append_not_mut)\n' + + 'extends native concat(self: StringBuilder, s: String): StringBuilder;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: Cell = fizz.toCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertocell\n' + + '///\n' + + '@name(__tact_string_builder_end)\n' + + 'extends native toCell(self: StringBuilder): Cell;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a built `String` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: String = fizz.toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertostring\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toString(self: StringBuilder): String;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` as a `Slice` from a `StringBuilder`.\n' + + '/// An alias to `self.toCell().asSlice()`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StringBuilder = beginString();\n' + + '/// let fizz: Slice = s.toSlice();\n' + + '/// let buzz: Slice = s.toCell().asSlice();\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertoslice\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toSlice(self: StringBuilder): Slice;\n' + + '\n' + + '//\n' + + '// String conversion\n' + + '//\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (84 - 42).toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttostring\n' + + '///\n' + + 'asm extends fun toString(self: Int): String {\n' + + ' // x\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representation] of a fractional\n' + + '/// number, where `self` is the significant part of the number and `digits` is the number\n' + + '/// of digits in the fractional part.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (42).toFloatString(9); // "0.000000042"\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 134: [Invalid argument] — Thrown when the given `digits` value is out of range.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttofloatstring\n' + + '///\n' + + '/// [fixed-point representation]: https://en.wikipedia.org/wiki/Fixed-point_arithmetic\n' + + '/// [Invalid argument]: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'asm extends fun toFloatString(self: Int, digits: Int): String {\n' + + ' // x digits\n' + + '\n' + + ' DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representatio'... 6219 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginString', + loc: { start: 329, end: 340 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 344, end: 357 } + }, + typeArgs: [], + loc: { start: 344, end: 357 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_string', + loc: { start: 286, end: 320 } + } + }, + loc: { start: 280, end: 358 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginComment', + loc: { start: 830, end: 842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 846, end: 859 } + }, + typeArgs: [], + loc: { start: 846, end: 859 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_comment', + loc: { start: 786, end: 821 } + } + }, + loc: { start: 780, end: 860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginTailString', + loc: { start: 1341, end: 1356 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1360, end: 1373 } + }, + typeArgs: [], + loc: { start: 1360, end: 1373 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_tail_string', + loc: { start: 1293, end: 1332 } + } + }, + loc: { start: 1287, end: 1374 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginStringFromBuilder', + loc: { start: 1836, end: 1858 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1872, end: 1885 } + }, + typeArgs: [], + loc: { start: 1872, end: 1885 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'b', + loc: { start: 1859, end: 1860 } + }, + type: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1862, end: 1869 } }, + loc: { start: 1862, end: 1869 } + }, + loc: { start: 1859, end: 1869 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start', + loc: { start: 1800, end: 1827 } + } + }, + loc: { start: 1794, end: 1886 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'append', + loc: { start: 2328, end: 2334 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2356, end: 2357 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2359, end: 2365 } + }, + typeArgs: [], + loc: { start: 2359, end: 2365 } + }, + loc: { start: 2356, end: 2365 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append', + loc: { start: 2275, end: 2303 } + } + }, + loc: { start: 2269, end: 2367 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2341, end: 2354 } + }, + typeArgs: [], + loc: { start: 2341, end: 2354 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'concat', + loc: { start: 2880, end: 2886 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2920, end: 2933 } + }, + typeArgs: [], + loc: { start: 2920, end: 2933 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2908, end: 2909 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2911, end: 2917 } + }, + typeArgs: [], + loc: { start: 2911, end: 2917 } + }, + loc: { start: 2908, end: 2917 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append_not_mut', + loc: { start: 2827, end: 2863 } + } + }, + loc: { start: 2821, end: 2934 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2893, end: 2906 } + }, + typeArgs: [], + loc: { start: 2893, end: 2906 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toCell', + loc: { start: 3392, end: 3398 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3421, end: 3425 } }, + loc: { start: 3421, end: 3425 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end', + loc: { start: 3350, end: 3375 } + } + }, + loc: { start: 3344, end: 3426 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3405, end: 3418 } + }, + typeArgs: [], + loc: { start: 3405, end: 3418 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 3893, end: 3901 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3924, end: 3930 } + }, + typeArgs: [], + loc: { start: 3924, end: 3930 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 3845, end: 3876 } + } + }, + loc: { start: 3839, end: 3931 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3908, end: 3921 } + }, + typeArgs: [], + loc: { start: 3908, end: 3921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toSlice', + loc: { start: 4530, end: 4537 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 4560, end: 4565 } }, + loc: { start: 4560, end: 4565 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 4482, end: 4513 } + } + }, + loc: { start: 4476, end: 4566 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 4544, end: 4557 } + }, + typeArgs: [], + loc: { start: 4544, end: 4557 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 4950, end: 4958 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 4971, end: 4977 } + }, + typeArgs: [], + loc: { start: 4971, end: 4977 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 4934, end: 5692 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4965, end: 4968 } + }, + loc: { start: 4965, end: 4968 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toFloatString', + loc: { start: 6527, end: 6540 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 6566, end: 6572 } + }, + typeArgs: [], + loc: { start: 6566, end: 6572 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'digits', + loc: { start: 6552, end: 6558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6552, end: 6563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 6511, end: 9874 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6547, end: 6550 } + }, + loc: { start: 6547, end: 6550 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'toCoinsString', + loc: { start: 10653, end: 10666 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 10679, end: 10685 } + }, + typeArgs: [], + loc: { start: 10679, end: 10685 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 10699, end: 10703 } + }, + method: { + kind: 'id', + text: 'toFloatString', + loc: { start: 10704, end: 10717 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 9n, + loc: { start: 10718, end: 10719 } + } + ], + loc: { start: 10699, end: 10720 } + }, + loc: { start: 10692, end: 10721 } + } + ] + }, + loc: { start: 10634, end: 10723 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10673, end: 10676 } + }, + loc: { start: 10673, end: 10676 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asComment', + loc: { start: 11442, end: 11451 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 11467, end: 11471 } + }, + loc: { start: 11467, end: 11471 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'b', + loc: { start: 11482, end: 11483 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 11485, end: 11498 } + }, + typeArgs: [], + loc: { start: 11485, end: 11498 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginComment', + loc: { start: 11501, end: 11513 } + }, + typeArgs: [], + args: [], + loc: { start: 11501, end: 11515 } + }, + loc: { start: 11478, end: 11516 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11521, end: 11522 } + }, + method: { + kind: 'id', + text: 'append', + loc: { start: 11523, end: 11529 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 11530, end: 11534 } + } + ], + loc: { start: 11521, end: 11535 } + }, + loc: { start: 11521, end: 11536 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11548, end: 11549 } + }, + method: { + kind: 'id', + text: 'toCell', + loc: { start: 11550, end: 11556 } + }, + typeArgs: [], + args: [], + loc: { start: 11548, end: 11558 } + }, + loc: { start: 11541, end: 11559 } + } + ] + }, + loc: { start: 11430, end: 11561 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 11458, end: 11464 } + }, + typeArgs: [], + loc: { start: 11458, end: 11464 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 12075, end: 12082 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 12098, end: 12103 } + }, + loc: { start: 12098, end: 12103 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_str_to_slice', + loc: { start: 12039, end: 12058 } + } + }, + loc: { start: 12033, end: 12104 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12089, end: 12095 } + }, + typeArgs: [], + loc: { start: 12089, end: 12095 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asString', + loc: { start: 12598, end: 12606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12621, end: 12627 } + }, + typeArgs: [], + loc: { start: 12621, end: 12627 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_slice_to_str', + loc: { start: 12562, end: 12581 } + } + }, + loc: { start: 12556, end: 12628 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 12613, end: 12618 } }, + loc: { start: 12613, end: 12618 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13537, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 13563, end: 13568 } + }, + loc: { start: 13563, end: 13568 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 13582, end: 13586 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 13587, end: 13594 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13596 } + }, + method: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13597, end: 13607 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13609 } + }, + loc: { start: 13575, end: 13610 } + } + ] + }, + loc: { start: 13518, end: 13612 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 13554, end: 13560 } + }, + typeArgs: [], + loc: { start: 13554, end: 13560 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 14642, end: 14652 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 14667, end: 14672 } + }, + loc: { start: 14667, end: 14672 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'size', + loc: { start: 14683, end: 14687 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14689, end: 14692 } + }, + loc: { start: 14689, end: 14692 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14695, end: 14699 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 14700, end: 14704 } + }, + typeArgs: [], + args: [], + loc: { start: 14695, end: 14706 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14709, end: 14710 } + }, + loc: { start: 14695, end: 14710 } + }, + loc: { start: 14679, end: 14711 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 14720, end: 14726 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 14728, end: 14735 } + }, + loc: { start: 14728, end: 14735 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 14738, end: 14747 } + }, + typeArgs: [], + args: [], + loc: { start: 14738, end: 14749 } + }, + loc: { start: 14716, end: 14750 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'size', + loc: { start: 14764, end: 14768 } + }, + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'code', + loc: { start: 14784, end: 14788 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14790, end: 14793 } + }, + loc: { start: 14790, end: 14793 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14796, end: 14800 } + }, + method: { + kind: 'id', + text: 'loadUint', + loc: { start: 14801, end: 14809 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14810, end: 14811 } + } + ], + loc: { start: 14796, end: 14812 } + }, + loc: { start: 14780, end: 14813 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14826, end: 14830 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14834, end: 14836 } + }, + loc: { start: 14826, end: 14836 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14840, end: 14844 } + }, + right: { + kind: 'number', + base: '10', + value: 90n, + loc: { start: 14848, end: 14850 } + }, + loc: { start: 14840, end: 14850 } + }, + loc: { start: 14826, end: 14850 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14873, end: 14879 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14882, end: 14888 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14889, end: 14898 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 14899, end: 14903 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14906, end: 14908 } + }, + loc: { start: 14899, end: 14908 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 14910, end: 14911 } + } + ], + loc: { start: 14882, end: 14912 } + }, + loc: { start: 14873, end: 14913 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14933, end: 14937 } + }, + right: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 14941, end: 14943 } + }, + loc: { start: 14933, end: 14943 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14947, end: 14951 } + }, + right: { + kind: 'number', + base: '10', + value: 122n, + loc: { start: 14955, end: 14958 } + }, + loc: { start: 14947, end: 14958 } + }, + loc: { start: 14933, end: 14958 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14981, end: 14987 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14990, end: 14996 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14997, end: 15006 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 15007, end: 15011 } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 15015, end: 15017 } + }, + right: { + kind: 'number', + base: '10', + value: 26n, + loc: { start: 15020, end: 15022 } + }, + loc: { start: 15015, end: 15022 } + }, + loc: { start: 15007, end: 15023 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15025, end: 15026 } + } + ], + loc: { start: 14990, end: 15027 } + }, + loc: { start: 14981, end: 15028 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15048, end: 15052 } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { start: 15056, end: 15058 } + }, + loc: { start: 15048, end: 15058 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15062, end: 15066 } + }, + right: { + kind: 'number', + base: '10', + value: 57n, + loc: { start: 15070, end: 15072 } + }, + loc: { start: 15062, end: 15072 } + }, + loc: { start: 15048, end: 15072 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15095, end: 15101 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15104, end: 15110 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 15111, end: 15120 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15121, + end: 15125 + } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 52n, + loc: { + start: 15129, + end: 15131 + } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { + start: 15134, + end: 15136 + } + }, + loc: { + start: 15129, + end: 15136 + } + }, + loc: { start: 15121, end: 15137 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15139, end: 15140 } + } + ], + loc: { start: 15104, end: 15141 } + }, + loc: { start: 15095, end: 15142 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15162, end: 15166 } + }, + right: { + kind: 'number', + base: '10', + value: 45n, + loc: { start: 15170, end: 15172 } + }, + loc: { start: 15162, end: 15172 } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15176, end: 15180 } + }, + right: { + kind: 'number', + base: '10', + value: 43n, + loc: { start: 15184, end: 15186 } + }, + loc: { start: 15176, end: 15186 } + }, + loc: { start: 15162, end: 15186 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15212, end: 15218 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15221, + end: 15227 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15228, + end: 15237 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 62n, + loc: { + start: 15238, + end: 15240 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15242, + end: 15243 + } + } + ], + loc: { start: 15221, end: 15244 } + }, + loc: { start: 15212, end: 15245 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15265, + end: 15269 + } + }, + right: { + kind: 'number', + base: '10', + value: 95n, + loc: { + start: 15273, + end: 15275 + } + }, + loc: { + start: 15265, + end: 15275 + } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15279, + end: 15283 + } + }, + right: { + kind: 'number', + base: '10', + value: 47n, + loc: { + start: 15287, + end: 15289 + } + }, + loc: { + start: 15279, + end: 15289 + } + }, + loc: { start: 15265, end: 15289 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 15315, + end: 15321 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15324, + end: 15330 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15331, + end: 15340 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 63n, + loc: { + start: 15341, + end: 15343 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15345, + end: 15346 + } + } + ], + loc: { + start: 15324, + end: 15347 + } + }, + loc: { + start: 15315, + end: 15348 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15368, + end: 15372 + } + }, + right: { + kind: 'number', + base: '10', + value: 61n, + loc: { + start: 15376, + end: 15378 + } + }, + loc: { + start: 15368, + end: 15378 + } + }, + trueStatements: [], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throw', + loc: { + start: 15436, + end: 15441 + } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidArgument', + loc: { + start: 15442, + end: 15469 + } + } + ], + loc: { + start: 15436, + end: 15470 + } + }, + loc: { + start: 15436, + end: 15471 + } + } + ], + loc: { + start: 15364, + end: 15481 + } + } + ], + loc: { start: 15261, end: 15481 } + } + ], + loc: { start: 15158, end: 15481 } + } + ], + loc: { start: 15044, end: 15481 } + } + ], + loc: { start: 14929, end: 15481 } + } + ], + loc: { start: 14822, end: 15481 } + } + ], + loc: { start: 14756, end: 15487 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'total', + loc: { start: 15512, end: 15517 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15519, end: 15522 } + }, + loc: { start: 15519, end: 15522 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15525, end: 15531 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 15532, end: 15536 } + }, + typeArgs: [], + args: [], + loc: { start: 15525, end: 15538 } + }, + loc: { start: 15508, end: 15539 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'padding', + loc: { start: 15548, end: 15555 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15557, end: 15560 } + }, + loc: { start: 15557, end: 15560 } + }, + expression: { + kind: 'op_binary', + op: '%', + left: { + kind: 'var', + name: 'total', + loc: { start: 15563, end: 15568 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 15571, end: 15572 } + }, + loc: { start: 15563, end: 15572 } + }, + loc: { start: 15544, end: 15573 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '!=', + left: { + kind: 'var', + name: 'padding', + loc: { start: 15582, end: 15589 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15593, end: 15594 } + }, + loc: { start: 15582, end: 15594 } + }, + trueStatements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15610, end: 15611 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 15613, end: 15618 } + }, + loc: { start: 15613, end: 15618 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15621, end: 15627 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15628, end: 15635 } + }, + typeArgs: [], + args: [], + loc: { start: 15621, end: 15637 } + }, + loc: { start: 15606, end: 15638 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 's', + loc: { start: 15654, end: 15655 } + }, + method: { + kind: 'id', + text: 'loadBits', + loc: { start: 15656, end: 15664 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'total', + loc: { start: 15665, end: 15670 } + }, + right: { + kind: 'var', + name: 'padding', + loc: { start: 15673, end: 15680 } + }, + loc: { start: 15665, end: 15680 } + } + ], + loc: { start: 15654, end: 15681 } + }, + loc: { start: 15647, end: 15682 } + } + ], + falseStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15711, end: 15717 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15718, end: 15725 } + }, + typeArgs: [], + args: [], + loc: { start: 15711, end: 15727 } + }, + loc: { start: 15704, end: 15728 } + } + ], + loc: { start: 15578, end: 15734 } + } + ] + }, + loc: { start: 14630, end: 15736 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 14659, end: 14664 } }, + loc: { start: 14659, end: 14664 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 16186, end: 16194 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 16211, end: 16217 } + }, + typeArgs: [], + loc: { start: 16211, end: 16217 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_address_to_user_friendly', + loc: { start: 16138, end: 16169 } + } + }, + loc: { start: 16132, end: 16218 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 16201, end: 16208 } + }, + typeArgs: [], + loc: { start: 16201, end: 16208 } + } + } + ] + }, + 'beginTailString' => { + kind: 'tact', + path: 'std/internal/text.tact', + code: '//\n' + + '// String builder\n' + + '//\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstring\n' + + '///\n' + + '@name(__tact_string_builder_start_string)\n' + + 'native beginString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a comment string, which prefixes\n' + + '/// the resulting `String` with four null bytes. This format is used for passing text comments\n' + + '/// as message bodies.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginComment();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begincomment\n' + + '///\n' + + '@name(__tact_string_builder_start_comment)\n' + + 'native beginComment(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a tail string, which prefixes\n' + + '/// the resulting `String` with a single null byte. This format is used in various standards\n' + + '/// such as NFT or Jetton.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginTailString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begintailstring\n' + + '///\n' + + '@name(__tact_string_builder_start_tail_string)\n' + + 'native beginTailString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns a new `StringBuilder` from an existing `StringBuilder` `b`. Useful when\n' + + '/// you need to serialize an existing `String` to a `Cell` along with other data.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginStringFromBuilder(beginString());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstringfrombuilder\n' + + '///\n' + + '@name(__tact_string_builder_start)\n' + + 'native beginStringFromBuilder(b: Builder): StringBuilder;\n' + + '\n' + + '/// Extension mutation function for the `StringBuilder` type.\n' + + '///\n' + + '/// Appends a `String` `s` to the `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// fizz.append("oh");\n' + + '/// fizz.append("my");\n' + + '/// fizz.append("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderappend\n' + + '///\n' + + '@name(__tact_string_builder_append)\n' + + 'extends mutates native append(self: StringBuilder, s: String);\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a new `StringBuilder` after concatenating it with a `String` `s`. It can be chained,\n' + + '/// unlike `StringBuilder.append()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString()\n' + + '/// .concat("oh")\n' + + '/// .concat("my")\n' + + '/// .concat("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderconcat\n' + + '///\n' + + '@name(__tact_string_builder_append_not_mut)\n' + + 'extends native concat(self: StringBuilder, s: String): StringBuilder;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: Cell = fizz.toCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertocell\n' + + '///\n' + + '@name(__tact_string_builder_end)\n' + + 'extends native toCell(self: StringBuilder): Cell;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a built `String` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: String = fizz.toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertostring\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toString(self: StringBuilder): String;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` as a `Slice` from a `StringBuilder`.\n' + + '/// An alias to `self.toCell().asSlice()`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StringBuilder = beginString();\n' + + '/// let fizz: Slice = s.toSlice();\n' + + '/// let buzz: Slice = s.toCell().asSlice();\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertoslice\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toSlice(self: StringBuilder): Slice;\n' + + '\n' + + '//\n' + + '// String conversion\n' + + '//\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (84 - 42).toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttostring\n' + + '///\n' + + 'asm extends fun toString(self: Int): String {\n' + + ' // x\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representation] of a fractional\n' + + '/// number, where `self` is the significant part of the number and `digits` is the number\n' + + '/// of digits in the fractional part.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (42).toFloatString(9); // "0.000000042"\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 134: [Invalid argument] — Thrown when the given `digits` value is out of range.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttofloatstring\n' + + '///\n' + + '/// [fixed-point representation]: https://en.wikipedia.org/wiki/Fixed-point_arithmetic\n' + + '/// [Invalid argument]: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'asm extends fun toFloatString(self: Int, digits: Int): String {\n' + + ' // x digits\n' + + '\n' + + ' DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representatio'... 6219 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginString', + loc: { start: 329, end: 340 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 344, end: 357 } + }, + typeArgs: [], + loc: { start: 344, end: 357 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_string', + loc: { start: 286, end: 320 } + } + }, + loc: { start: 280, end: 358 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginComment', + loc: { start: 830, end: 842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 846, end: 859 } + }, + typeArgs: [], + loc: { start: 846, end: 859 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_comment', + loc: { start: 786, end: 821 } + } + }, + loc: { start: 780, end: 860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginTailString', + loc: { start: 1341, end: 1356 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1360, end: 1373 } + }, + typeArgs: [], + loc: { start: 1360, end: 1373 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_tail_string', + loc: { start: 1293, end: 1332 } + } + }, + loc: { start: 1287, end: 1374 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginStringFromBuilder', + loc: { start: 1836, end: 1858 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1872, end: 1885 } + }, + typeArgs: [], + loc: { start: 1872, end: 1885 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'b', + loc: { start: 1859, end: 1860 } + }, + type: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1862, end: 1869 } }, + loc: { start: 1862, end: 1869 } + }, + loc: { start: 1859, end: 1869 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start', + loc: { start: 1800, end: 1827 } + } + }, + loc: { start: 1794, end: 1886 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'append', + loc: { start: 2328, end: 2334 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2356, end: 2357 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2359, end: 2365 } + }, + typeArgs: [], + loc: { start: 2359, end: 2365 } + }, + loc: { start: 2356, end: 2365 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append', + loc: { start: 2275, end: 2303 } + } + }, + loc: { start: 2269, end: 2367 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2341, end: 2354 } + }, + typeArgs: [], + loc: { start: 2341, end: 2354 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'concat', + loc: { start: 2880, end: 2886 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2920, end: 2933 } + }, + typeArgs: [], + loc: { start: 2920, end: 2933 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2908, end: 2909 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2911, end: 2917 } + }, + typeArgs: [], + loc: { start: 2911, end: 2917 } + }, + loc: { start: 2908, end: 2917 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append_not_mut', + loc: { start: 2827, end: 2863 } + } + }, + loc: { start: 2821, end: 2934 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2893, end: 2906 } + }, + typeArgs: [], + loc: { start: 2893, end: 2906 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toCell', + loc: { start: 3392, end: 3398 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3421, end: 3425 } }, + loc: { start: 3421, end: 3425 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end', + loc: { start: 3350, end: 3375 } + } + }, + loc: { start: 3344, end: 3426 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3405, end: 3418 } + }, + typeArgs: [], + loc: { start: 3405, end: 3418 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 3893, end: 3901 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3924, end: 3930 } + }, + typeArgs: [], + loc: { start: 3924, end: 3930 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 3845, end: 3876 } + } + }, + loc: { start: 3839, end: 3931 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3908, end: 3921 } + }, + typeArgs: [], + loc: { start: 3908, end: 3921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toSlice', + loc: { start: 4530, end: 4537 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 4560, end: 4565 } }, + loc: { start: 4560, end: 4565 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 4482, end: 4513 } + } + }, + loc: { start: 4476, end: 4566 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 4544, end: 4557 } + }, + typeArgs: [], + loc: { start: 4544, end: 4557 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 4950, end: 4958 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 4971, end: 4977 } + }, + typeArgs: [], + loc: { start: 4971, end: 4977 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 4934, end: 5692 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4965, end: 4968 } + }, + loc: { start: 4965, end: 4968 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toFloatString', + loc: { start: 6527, end: 6540 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 6566, end: 6572 } + }, + typeArgs: [], + loc: { start: 6566, end: 6572 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'digits', + loc: { start: 6552, end: 6558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6552, end: 6563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 6511, end: 9874 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6547, end: 6550 } + }, + loc: { start: 6547, end: 6550 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'toCoinsString', + loc: { start: 10653, end: 10666 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 10679, end: 10685 } + }, + typeArgs: [], + loc: { start: 10679, end: 10685 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 10699, end: 10703 } + }, + method: { + kind: 'id', + text: 'toFloatString', + loc: { start: 10704, end: 10717 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 9n, + loc: { start: 10718, end: 10719 } + } + ], + loc: { start: 10699, end: 10720 } + }, + loc: { start: 10692, end: 10721 } + } + ] + }, + loc: { start: 10634, end: 10723 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10673, end: 10676 } + }, + loc: { start: 10673, end: 10676 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asComment', + loc: { start: 11442, end: 11451 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 11467, end: 11471 } + }, + loc: { start: 11467, end: 11471 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'b', + loc: { start: 11482, end: 11483 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 11485, end: 11498 } + }, + typeArgs: [], + loc: { start: 11485, end: 11498 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginComment', + loc: { start: 11501, end: 11513 } + }, + typeArgs: [], + args: [], + loc: { start: 11501, end: 11515 } + }, + loc: { start: 11478, end: 11516 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11521, end: 11522 } + }, + method: { + kind: 'id', + text: 'append', + loc: { start: 11523, end: 11529 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 11530, end: 11534 } + } + ], + loc: { start: 11521, end: 11535 } + }, + loc: { start: 11521, end: 11536 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11548, end: 11549 } + }, + method: { + kind: 'id', + text: 'toCell', + loc: { start: 11550, end: 11556 } + }, + typeArgs: [], + args: [], + loc: { start: 11548, end: 11558 } + }, + loc: { start: 11541, end: 11559 } + } + ] + }, + loc: { start: 11430, end: 11561 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 11458, end: 11464 } + }, + typeArgs: [], + loc: { start: 11458, end: 11464 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 12075, end: 12082 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 12098, end: 12103 } + }, + loc: { start: 12098, end: 12103 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_str_to_slice', + loc: { start: 12039, end: 12058 } + } + }, + loc: { start: 12033, end: 12104 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12089, end: 12095 } + }, + typeArgs: [], + loc: { start: 12089, end: 12095 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asString', + loc: { start: 12598, end: 12606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12621, end: 12627 } + }, + typeArgs: [], + loc: { start: 12621, end: 12627 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_slice_to_str', + loc: { start: 12562, end: 12581 } + } + }, + loc: { start: 12556, end: 12628 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 12613, end: 12618 } }, + loc: { start: 12613, end: 12618 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13537, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 13563, end: 13568 } + }, + loc: { start: 13563, end: 13568 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 13582, end: 13586 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 13587, end: 13594 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13596 } + }, + method: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13597, end: 13607 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13609 } + }, + loc: { start: 13575, end: 13610 } + } + ] + }, + loc: { start: 13518, end: 13612 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 13554, end: 13560 } + }, + typeArgs: [], + loc: { start: 13554, end: 13560 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 14642, end: 14652 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 14667, end: 14672 } + }, + loc: { start: 14667, end: 14672 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'size', + loc: { start: 14683, end: 14687 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14689, end: 14692 } + }, + loc: { start: 14689, end: 14692 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14695, end: 14699 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 14700, end: 14704 } + }, + typeArgs: [], + args: [], + loc: { start: 14695, end: 14706 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14709, end: 14710 } + }, + loc: { start: 14695, end: 14710 } + }, + loc: { start: 14679, end: 14711 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 14720, end: 14726 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 14728, end: 14735 } + }, + loc: { start: 14728, end: 14735 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 14738, end: 14747 } + }, + typeArgs: [], + args: [], + loc: { start: 14738, end: 14749 } + }, + loc: { start: 14716, end: 14750 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'size', + loc: { start: 14764, end: 14768 } + }, + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'code', + loc: { start: 14784, end: 14788 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14790, end: 14793 } + }, + loc: { start: 14790, end: 14793 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14796, end: 14800 } + }, + method: { + kind: 'id', + text: 'loadUint', + loc: { start: 14801, end: 14809 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14810, end: 14811 } + } + ], + loc: { start: 14796, end: 14812 } + }, + loc: { start: 14780, end: 14813 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14826, end: 14830 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14834, end: 14836 } + }, + loc: { start: 14826, end: 14836 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14840, end: 14844 } + }, + right: { + kind: 'number', + base: '10', + value: 90n, + loc: { start: 14848, end: 14850 } + }, + loc: { start: 14840, end: 14850 } + }, + loc: { start: 14826, end: 14850 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14873, end: 14879 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14882, end: 14888 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14889, end: 14898 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 14899, end: 14903 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14906, end: 14908 } + }, + loc: { start: 14899, end: 14908 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 14910, end: 14911 } + } + ], + loc: { start: 14882, end: 14912 } + }, + loc: { start: 14873, end: 14913 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14933, end: 14937 } + }, + right: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 14941, end: 14943 } + }, + loc: { start: 14933, end: 14943 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14947, end: 14951 } + }, + right: { + kind: 'number', + base: '10', + value: 122n, + loc: { start: 14955, end: 14958 } + }, + loc: { start: 14947, end: 14958 } + }, + loc: { start: 14933, end: 14958 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14981, end: 14987 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14990, end: 14996 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14997, end: 15006 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 15007, end: 15011 } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 15015, end: 15017 } + }, + right: { + kind: 'number', + base: '10', + value: 26n, + loc: { start: 15020, end: 15022 } + }, + loc: { start: 15015, end: 15022 } + }, + loc: { start: 15007, end: 15023 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15025, end: 15026 } + } + ], + loc: { start: 14990, end: 15027 } + }, + loc: { start: 14981, end: 15028 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15048, end: 15052 } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { start: 15056, end: 15058 } + }, + loc: { start: 15048, end: 15058 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15062, end: 15066 } + }, + right: { + kind: 'number', + base: '10', + value: 57n, + loc: { start: 15070, end: 15072 } + }, + loc: { start: 15062, end: 15072 } + }, + loc: { start: 15048, end: 15072 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15095, end: 15101 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15104, end: 15110 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 15111, end: 15120 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15121, + end: 15125 + } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 52n, + loc: { + start: 15129, + end: 15131 + } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { + start: 15134, + end: 15136 + } + }, + loc: { + start: 15129, + end: 15136 + } + }, + loc: { start: 15121, end: 15137 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15139, end: 15140 } + } + ], + loc: { start: 15104, end: 15141 } + }, + loc: { start: 15095, end: 15142 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15162, end: 15166 } + }, + right: { + kind: 'number', + base: '10', + value: 45n, + loc: { start: 15170, end: 15172 } + }, + loc: { start: 15162, end: 15172 } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15176, end: 15180 } + }, + right: { + kind: 'number', + base: '10', + value: 43n, + loc: { start: 15184, end: 15186 } + }, + loc: { start: 15176, end: 15186 } + }, + loc: { start: 15162, end: 15186 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15212, end: 15218 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15221, + end: 15227 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15228, + end: 15237 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 62n, + loc: { + start: 15238, + end: 15240 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15242, + end: 15243 + } + } + ], + loc: { start: 15221, end: 15244 } + }, + loc: { start: 15212, end: 15245 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15265, + end: 15269 + } + }, + right: { + kind: 'number', + base: '10', + value: 95n, + loc: { + start: 15273, + end: 15275 + } + }, + loc: { + start: 15265, + end: 15275 + } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15279, + end: 15283 + } + }, + right: { + kind: 'number', + base: '10', + value: 47n, + loc: { + start: 15287, + end: 15289 + } + }, + loc: { + start: 15279, + end: 15289 + } + }, + loc: { start: 15265, end: 15289 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 15315, + end: 15321 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15324, + end: 15330 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15331, + end: 15340 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 63n, + loc: { + start: 15341, + end: 15343 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15345, + end: 15346 + } + } + ], + loc: { + start: 15324, + end: 15347 + } + }, + loc: { + start: 15315, + end: 15348 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15368, + end: 15372 + } + }, + right: { + kind: 'number', + base: '10', + value: 61n, + loc: { + start: 15376, + end: 15378 + } + }, + loc: { + start: 15368, + end: 15378 + } + }, + trueStatements: [], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throw', + loc: { + start: 15436, + end: 15441 + } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidArgument', + loc: { + start: 15442, + end: 15469 + } + } + ], + loc: { + start: 15436, + end: 15470 + } + }, + loc: { + start: 15436, + end: 15471 + } + } + ], + loc: { + start: 15364, + end: 15481 + } + } + ], + loc: { start: 15261, end: 15481 } + } + ], + loc: { start: 15158, end: 15481 } + } + ], + loc: { start: 15044, end: 15481 } + } + ], + loc: { start: 14929, end: 15481 } + } + ], + loc: { start: 14822, end: 15481 } + } + ], + loc: { start: 14756, end: 15487 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'total', + loc: { start: 15512, end: 15517 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15519, end: 15522 } + }, + loc: { start: 15519, end: 15522 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15525, end: 15531 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 15532, end: 15536 } + }, + typeArgs: [], + args: [], + loc: { start: 15525, end: 15538 } + }, + loc: { start: 15508, end: 15539 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'padding', + loc: { start: 15548, end: 15555 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15557, end: 15560 } + }, + loc: { start: 15557, end: 15560 } + }, + expression: { + kind: 'op_binary', + op: '%', + left: { + kind: 'var', + name: 'total', + loc: { start: 15563, end: 15568 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 15571, end: 15572 } + }, + loc: { start: 15563, end: 15572 } + }, + loc: { start: 15544, end: 15573 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '!=', + left: { + kind: 'var', + name: 'padding', + loc: { start: 15582, end: 15589 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15593, end: 15594 } + }, + loc: { start: 15582, end: 15594 } + }, + trueStatements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15610, end: 15611 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 15613, end: 15618 } + }, + loc: { start: 15613, end: 15618 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15621, end: 15627 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15628, end: 15635 } + }, + typeArgs: [], + args: [], + loc: { start: 15621, end: 15637 } + }, + loc: { start: 15606, end: 15638 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 's', + loc: { start: 15654, end: 15655 } + }, + method: { + kind: 'id', + text: 'loadBits', + loc: { start: 15656, end: 15664 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'total', + loc: { start: 15665, end: 15670 } + }, + right: { + kind: 'var', + name: 'padding', + loc: { start: 15673, end: 15680 } + }, + loc: { start: 15665, end: 15680 } + } + ], + loc: { start: 15654, end: 15681 } + }, + loc: { start: 15647, end: 15682 } + } + ], + falseStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15711, end: 15717 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15718, end: 15725 } + }, + typeArgs: [], + args: [], + loc: { start: 15711, end: 15727 } + }, + loc: { start: 15704, end: 15728 } + } + ], + loc: { start: 15578, end: 15734 } + } + ] + }, + loc: { start: 14630, end: 15736 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 14659, end: 14664 } }, + loc: { start: 14659, end: 14664 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 16186, end: 16194 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 16211, end: 16217 } + }, + typeArgs: [], + loc: { start: 16211, end: 16217 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_address_to_user_friendly', + loc: { start: 16138, end: 16169 } + } + }, + loc: { start: 16132, end: 16218 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 16201, end: 16208 } + }, + typeArgs: [], + loc: { start: 16201, end: 16208 } + } + } + ] + }, + 'beginStringFromBuilder' => { + kind: 'tact', + path: 'std/internal/text.tact', + code: '//\n' + + '// String builder\n' + + '//\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstring\n' + + '///\n' + + '@name(__tact_string_builder_start_string)\n' + + 'native beginString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a comment string, which prefixes\n' + + '/// the resulting `String` with four null bytes. This format is used for passing text comments\n' + + '/// as message bodies.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginComment();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begincomment\n' + + '///\n' + + '@name(__tact_string_builder_start_comment)\n' + + 'native beginComment(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a tail string, which prefixes\n' + + '/// the resulting `String` with a single null byte. This format is used in various standards\n' + + '/// such as NFT or Jetton.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginTailString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begintailstring\n' + + '///\n' + + '@name(__tact_string_builder_start_tail_string)\n' + + 'native beginTailString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns a new `StringBuilder` from an existing `StringBuilder` `b`. Useful when\n' + + '/// you need to serialize an existing `String` to a `Cell` along with other data.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginStringFromBuilder(beginString());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstringfrombuilder\n' + + '///\n' + + '@name(__tact_string_builder_start)\n' + + 'native beginStringFromBuilder(b: Builder): StringBuilder;\n' + + '\n' + + '/// Extension mutation function for the `StringBuilder` type.\n' + + '///\n' + + '/// Appends a `String` `s` to the `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// fizz.append("oh");\n' + + '/// fizz.append("my");\n' + + '/// fizz.append("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderappend\n' + + '///\n' + + '@name(__tact_string_builder_append)\n' + + 'extends mutates native append(self: StringBuilder, s: String);\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a new `StringBuilder` after concatenating it with a `String` `s`. It can be chained,\n' + + '/// unlike `StringBuilder.append()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString()\n' + + '/// .concat("oh")\n' + + '/// .concat("my")\n' + + '/// .concat("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderconcat\n' + + '///\n' + + '@name(__tact_string_builder_append_not_mut)\n' + + 'extends native concat(self: StringBuilder, s: String): StringBuilder;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: Cell = fizz.toCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertocell\n' + + '///\n' + + '@name(__tact_string_builder_end)\n' + + 'extends native toCell(self: StringBuilder): Cell;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a built `String` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: String = fizz.toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertostring\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toString(self: StringBuilder): String;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` as a `Slice` from a `StringBuilder`.\n' + + '/// An alias to `self.toCell().asSlice()`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StringBuilder = beginString();\n' + + '/// let fizz: Slice = s.toSlice();\n' + + '/// let buzz: Slice = s.toCell().asSlice();\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertoslice\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toSlice(self: StringBuilder): Slice;\n' + + '\n' + + '//\n' + + '// String conversion\n' + + '//\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (84 - 42).toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttostring\n' + + '///\n' + + 'asm extends fun toString(self: Int): String {\n' + + ' // x\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representation] of a fractional\n' + + '/// number, where `self` is the significant part of the number and `digits` is the number\n' + + '/// of digits in the fractional part.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (42).toFloatString(9); // "0.000000042"\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 134: [Invalid argument] — Thrown when the given `digits` value is out of range.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttofloatstring\n' + + '///\n' + + '/// [fixed-point representation]: https://en.wikipedia.org/wiki/Fixed-point_arithmetic\n' + + '/// [Invalid argument]: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'asm extends fun toFloatString(self: Int, digits: Int): String {\n' + + ' // x digits\n' + + '\n' + + ' DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representatio'... 6219 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginString', + loc: { start: 329, end: 340 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 344, end: 357 } + }, + typeArgs: [], + loc: { start: 344, end: 357 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_string', + loc: { start: 286, end: 320 } + } + }, + loc: { start: 280, end: 358 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginComment', + loc: { start: 830, end: 842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 846, end: 859 } + }, + typeArgs: [], + loc: { start: 846, end: 859 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_comment', + loc: { start: 786, end: 821 } + } + }, + loc: { start: 780, end: 860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginTailString', + loc: { start: 1341, end: 1356 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1360, end: 1373 } + }, + typeArgs: [], + loc: { start: 1360, end: 1373 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_tail_string', + loc: { start: 1293, end: 1332 } + } + }, + loc: { start: 1287, end: 1374 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginStringFromBuilder', + loc: { start: 1836, end: 1858 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1872, end: 1885 } + }, + typeArgs: [], + loc: { start: 1872, end: 1885 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'b', + loc: { start: 1859, end: 1860 } + }, + type: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 1862, end: 1869 } }, + loc: { start: 1862, end: 1869 } + }, + loc: { start: 1859, end: 1869 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start', + loc: { start: 1800, end: 1827 } + } + }, + loc: { start: 1794, end: 1886 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'append', + loc: { start: 2328, end: 2334 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2356, end: 2357 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2359, end: 2365 } + }, + typeArgs: [], + loc: { start: 2359, end: 2365 } + }, + loc: { start: 2356, end: 2365 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append', + loc: { start: 2275, end: 2303 } + } + }, + loc: { start: 2269, end: 2367 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2341, end: 2354 } + }, + typeArgs: [], + loc: { start: 2341, end: 2354 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'concat', + loc: { start: 2880, end: 2886 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2920, end: 2933 } + }, + typeArgs: [], + loc: { start: 2920, end: 2933 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2908, end: 2909 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2911, end: 2917 } + }, + typeArgs: [], + loc: { start: 2911, end: 2917 } + }, + loc: { start: 2908, end: 2917 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append_not_mut', + loc: { start: 2827, end: 2863 } + } + }, + loc: { start: 2821, end: 2934 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2893, end: 2906 } + }, + typeArgs: [], + loc: { start: 2893, end: 2906 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toCell', + loc: { start: 3392, end: 3398 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3421, end: 3425 } }, + loc: { start: 3421, end: 3425 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end', + loc: { start: 3350, end: 3375 } + } + }, + loc: { start: 3344, end: 3426 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3405, end: 3418 } + }, + typeArgs: [], + loc: { start: 3405, end: 3418 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 3893, end: 3901 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3924, end: 3930 } + }, + typeArgs: [], + loc: { start: 3924, end: 3930 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 3845, end: 3876 } + } + }, + loc: { start: 3839, end: 3931 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3908, end: 3921 } + }, + typeArgs: [], + loc: { start: 3908, end: 3921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toSlice', + loc: { start: 4530, end: 4537 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 4560, end: 4565 } }, + loc: { start: 4560, end: 4565 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 4482, end: 4513 } + } + }, + loc: { start: 4476, end: 4566 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 4544, end: 4557 } + }, + typeArgs: [], + loc: { start: 4544, end: 4557 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 4950, end: 4958 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 4971, end: 4977 } + }, + typeArgs: [], + loc: { start: 4971, end: 4977 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 4934, end: 5692 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4965, end: 4968 } + }, + loc: { start: 4965, end: 4968 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toFloatString', + loc: { start: 6527, end: 6540 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 6566, end: 6572 } + }, + typeArgs: [], + loc: { start: 6566, end: 6572 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'digits', + loc: { start: 6552, end: 6558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6552, end: 6563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 6511, end: 9874 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6547, end: 6550 } + }, + loc: { start: 6547, end: 6550 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'toCoinsString', + loc: { start: 10653, end: 10666 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 10679, end: 10685 } + }, + typeArgs: [], + loc: { start: 10679, end: 10685 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 10699, end: 10703 } + }, + method: { + kind: 'id', + text: 'toFloatString', + loc: { start: 10704, end: 10717 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 9n, + loc: { start: 10718, end: 10719 } + } + ], + loc: { start: 10699, end: 10720 } + }, + loc: { start: 10692, end: 10721 } + } + ] + }, + loc: { start: 10634, end: 10723 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10673, end: 10676 } + }, + loc: { start: 10673, end: 10676 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asComment', + loc: { start: 11442, end: 11451 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 11467, end: 11471 } + }, + loc: { start: 11467, end: 11471 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'b', + loc: { start: 11482, end: 11483 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 11485, end: 11498 } + }, + typeArgs: [], + loc: { start: 11485, end: 11498 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginComment', + loc: { start: 11501, end: 11513 } + }, + typeArgs: [], + args: [], + loc: { start: 11501, end: 11515 } + }, + loc: { start: 11478, end: 11516 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11521, end: 11522 } + }, + method: { + kind: 'id', + text: 'append', + loc: { start: 11523, end: 11529 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 11530, end: 11534 } + } + ], + loc: { start: 11521, end: 11535 } + }, + loc: { start: 11521, end: 11536 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11548, end: 11549 } + }, + method: { + kind: 'id', + text: 'toCell', + loc: { start: 11550, end: 11556 } + }, + typeArgs: [], + args: [], + loc: { start: 11548, end: 11558 } + }, + loc: { start: 11541, end: 11559 } + } + ] + }, + loc: { start: 11430, end: 11561 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 11458, end: 11464 } + }, + typeArgs: [], + loc: { start: 11458, end: 11464 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 12075, end: 12082 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 12098, end: 12103 } + }, + loc: { start: 12098, end: 12103 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_str_to_slice', + loc: { start: 12039, end: 12058 } + } + }, + loc: { start: 12033, end: 12104 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12089, end: 12095 } + }, + typeArgs: [], + loc: { start: 12089, end: 12095 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asString', + loc: { start: 12598, end: 12606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12621, end: 12627 } + }, + typeArgs: [], + loc: { start: 12621, end: 12627 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_slice_to_str', + loc: { start: 12562, end: 12581 } + } + }, + loc: { start: 12556, end: 12628 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 12613, end: 12618 } }, + loc: { start: 12613, end: 12618 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13537, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 13563, end: 13568 } + }, + loc: { start: 13563, end: 13568 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 13582, end: 13586 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 13587, end: 13594 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13596 } + }, + method: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13597, end: 13607 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13609 } + }, + loc: { start: 13575, end: 13610 } + } + ] + }, + loc: { start: 13518, end: 13612 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 13554, end: 13560 } + }, + typeArgs: [], + loc: { start: 13554, end: 13560 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 14642, end: 14652 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 14667, end: 14672 } + }, + loc: { start: 14667, end: 14672 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'size', + loc: { start: 14683, end: 14687 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14689, end: 14692 } + }, + loc: { start: 14689, end: 14692 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14695, end: 14699 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 14700, end: 14704 } + }, + typeArgs: [], + args: [], + loc: { start: 14695, end: 14706 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14709, end: 14710 } + }, + loc: { start: 14695, end: 14710 } + }, + loc: { start: 14679, end: 14711 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 14720, end: 14726 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 14728, end: 14735 } + }, + loc: { start: 14728, end: 14735 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 14738, end: 14747 } + }, + typeArgs: [], + args: [], + loc: { start: 14738, end: 14749 } + }, + loc: { start: 14716, end: 14750 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'size', + loc: { start: 14764, end: 14768 } + }, + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'code', + loc: { start: 14784, end: 14788 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14790, end: 14793 } + }, + loc: { start: 14790, end: 14793 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14796, end: 14800 } + }, + method: { + kind: 'id', + text: 'loadUint', + loc: { start: 14801, end: 14809 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14810, end: 14811 } + } + ], + loc: { start: 14796, end: 14812 } + }, + loc: { start: 14780, end: 14813 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14826, end: 14830 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14834, end: 14836 } + }, + loc: { start: 14826, end: 14836 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14840, end: 14844 } + }, + right: { + kind: 'number', + base: '10', + value: 90n, + loc: { start: 14848, end: 14850 } + }, + loc: { start: 14840, end: 14850 } + }, + loc: { start: 14826, end: 14850 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14873, end: 14879 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14882, end: 14888 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14889, end: 14898 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 14899, end: 14903 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14906, end: 14908 } + }, + loc: { start: 14899, end: 14908 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 14910, end: 14911 } + } + ], + loc: { start: 14882, end: 14912 } + }, + loc: { start: 14873, end: 14913 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14933, end: 14937 } + }, + right: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 14941, end: 14943 } + }, + loc: { start: 14933, end: 14943 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14947, end: 14951 } + }, + right: { + kind: 'number', + base: '10', + value: 122n, + loc: { start: 14955, end: 14958 } + }, + loc: { start: 14947, end: 14958 } + }, + loc: { start: 14933, end: 14958 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14981, end: 14987 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 14990, end: 14996 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 14997, end: 15006 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { start: 15007, end: 15011 } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 97n, + loc: { start: 15015, end: 15017 } + }, + right: { + kind: 'number', + base: '10', + value: 26n, + loc: { start: 15020, end: 15022 } + }, + loc: { start: 15015, end: 15022 } + }, + loc: { start: 15007, end: 15023 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15025, end: 15026 } + } + ], + loc: { start: 14990, end: 15027 } + }, + loc: { start: 14981, end: 15028 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15048, end: 15052 } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { start: 15056, end: 15058 } + }, + loc: { start: 15048, end: 15058 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 15062, end: 15066 } + }, + right: { + kind: 'number', + base: '10', + value: 57n, + loc: { start: 15070, end: 15072 } + }, + loc: { start: 15062, end: 15072 } + }, + loc: { start: 15048, end: 15072 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15095, end: 15101 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15104, end: 15110 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 15111, end: 15120 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15121, + end: 15125 + } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 52n, + loc: { + start: 15129, + end: 15131 + } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { + start: 15134, + end: 15136 + } + }, + loc: { + start: 15129, + end: 15136 + } + }, + loc: { start: 15121, end: 15137 } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { start: 15139, end: 15140 } + } + ], + loc: { start: 15104, end: 15141 } + }, + loc: { start: 15095, end: 15142 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15162, end: 15166 } + }, + right: { + kind: 'number', + base: '10', + value: 45n, + loc: { start: 15170, end: 15172 } + }, + loc: { start: 15162, end: 15172 } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { start: 15176, end: 15180 } + }, + right: { + kind: 'number', + base: '10', + value: 43n, + loc: { start: 15184, end: 15186 } + }, + loc: { start: 15176, end: 15186 } + }, + loc: { start: 15162, end: 15186 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 15212, end: 15218 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15221, + end: 15227 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15228, + end: 15237 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 62n, + loc: { + start: 15238, + end: 15240 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15242, + end: 15243 + } + } + ], + loc: { start: 15221, end: 15244 } + }, + loc: { start: 15212, end: 15245 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15265, + end: 15269 + } + }, + right: { + kind: 'number', + base: '10', + value: 95n, + loc: { + start: 15273, + end: 15275 + } + }, + loc: { + start: 15265, + end: 15275 + } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15279, + end: 15283 + } + }, + right: { + kind: 'number', + base: '10', + value: 47n, + loc: { + start: 15287, + end: 15289 + } + }, + loc: { + start: 15279, + end: 15289 + } + }, + loc: { start: 15265, end: 15289 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 15315, + end: 15321 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15324, + end: 15330 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15331, + end: 15340 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 63n, + loc: { + start: 15341, + end: 15343 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15345, + end: 15346 + } + } + ], + loc: { + start: 15324, + end: 15347 + } + }, + loc: { + start: 15315, + end: 15348 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15368, + end: 15372 + } + }, + right: { + kind: 'number', + base: '10', + value: 61n, + loc: { + start: 15376, + end: 15378 + } + }, + loc: { + start: 15368, + end: 15378 + } + }, + trueStatements: [], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throw', + loc: { + start: 15436, + end: 15441 + } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidArgument', + loc: { + start: 15442, + end: 15469 + } + } + ], + loc: { + start: 15436, + end: 15470 + } + }, + loc: { + start: 15436, + end: 15471 + } + } + ], + loc: { + start: 15364, + end: 15481 + } + } + ], + loc: { start: 15261, end: 15481 } + } + ], + loc: { start: 15158, end: 15481 } + } + ], + loc: { start: 15044, end: 15481 } + } + ], + loc: { start: 14929, end: 15481 } + } + ], + loc: { start: 14822, end: 15481 } + } + ], + loc: { start: 14756, end: 15487 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'total', + loc: { start: 15512, end: 15517 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15519, end: 15522 } + }, + loc: { start: 15519, end: 15522 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15525, end: 15531 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 15532, end: 15536 } + }, + typeArgs: [], + args: [], + loc: { start: 15525, end: 15538 } + }, + loc: { start: 15508, end: 15539 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'padding', + loc: { start: 15548, end: 15555 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15557, end: 15560 } + }, + loc: { start: 15557, end: 15560 } + }, + expression: { + kind: 'op_binary', + op: '%', + left: { + kind: 'var', + name: 'total', + loc: { start: 15563, end: 15568 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 15571, end: 15572 } + }, + loc: { start: 15563, end: 15572 } + }, + loc: { start: 15544, end: 15573 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '!=', + left: { + kind: 'var', + name: 'padding', + loc: { start: 15582, end: 15589 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15593, end: 15594 } + }, + loc: { start: 15582, end: 15594 } + }, + trueStatements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15610, end: 15611 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 15613, end: 15618 } + }, + loc: { start: 15613, end: 15618 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15621, end: 15627 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15628, end: 15635 } + }, + typeArgs: [], + args: [], + loc: { start: 15621, end: 15637 } + }, + loc: { start: 15606, end: 15638 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 's', + loc: { start: 15654, end: 15655 } + }, + method: { + kind: 'id', + text: 'loadBits', + loc: { start: 15656, end: 15664 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'total', + loc: { start: 15665, end: 15670 } + }, + right: { + kind: 'var', + name: 'padding', + loc: { start: 15673, end: 15680 } + }, + loc: { start: 15665, end: 15680 } + } + ], + loc: { start: 15654, end: 15681 } + }, + loc: { start: 15647, end: 15682 } + } + ], + falseStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15711, end: 15717 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15718, end: 15725 } + }, + typeArgs: [], + args: [], + loc: { start: 15711, end: 15727 } + }, + loc: { start: 15704, end: 15728 } + } + ], + loc: { start: 15578, end: 15734 } + } + ] + }, + loc: { start: 14630, end: 15736 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 14659, end: 14664 } }, + loc: { start: 14659, end: 14664 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 16186, end: 16194 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 16211, end: 16217 } + }, + typeArgs: [], + loc: { start: 16211, end: 16217 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_address_to_user_friendly', + loc: { start: 16138, end: 16169 } + } + }, + loc: { start: 16132, end: 16218 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 16201, end: 16208 } + }, + typeArgs: [], + loc: { start: 16201, end: 16208 } + } + } + ] + }, + 'nativeRandomize' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'nativeRandomizeLt' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'nativePrepareRandom' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'nativeRandom' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'nativeRandomInterval' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'randomInt' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'random' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'min' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'max' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'abs' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'log' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'log2' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'pow' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'pow2' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'sign' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'divc' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'muldivc' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'mulShiftRight' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'mulShiftRightRound' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'mulShiftRightCeil' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'sqrt' => { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'x', loc: { start: 981, end: 982 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'min', loc: { start: 5017, end: 5020 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'max', loc: { start: 5435, end: 5438 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'abs', loc: { start: 5773, end: 5776 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log', loc: { start: 6721, end: 6724 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'log2', loc: { start: 7341, end: 7345 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { kind: 'id', text: 'pow', loc: { start: 8510, end: 8513 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'pow2', loc: { start: 9733, end: 9737 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + 'contractHash' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'contractAddressExt' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'contractAddress' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'myAddress' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'myBalance' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'gasConsumed' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'myStorageDue' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'getStorageFee' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'getComputeFee' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'getSimpleComputeFee' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'getForwardFee' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'getSimpleForwardFee' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'getOriginalFwdFee' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'setGasLimit' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'getSeed' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'setSeed' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'myCode' => { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1046, end: 1050 } }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 1058, end: 1062 } }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3428, end: 3432 } }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3440, end: 3444 } }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3809, end: 3813 } }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 3920, end: 3924 } }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 18595, end: 18599 } }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + 'throw' => { + kind: 'tact', + path: 'std/internal/debug.tact', + code: '// these are builtin functions, these get special treatment from FunC\n' + + '// hence, no asm here\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Unconditionally throws an exception with an error `code`.\n' + + '///\n' + + '/// Execution of the current context stops, statements after `throw` are not executed, and control is passed to the first `try...catch` block on the call stack. If there is no `try` or `try...catch` block among the calling functions, TVM will terminate the transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun thisWillTerminateAbruptly() {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// fun butThisWont() {\n' + + '/// try {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw)\n' + + 'native throw(code: Int);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` holds, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwIf(1024, sender() != self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_if)\n' + + 'native throwIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` does **not** hold, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// This function is also similar to `require()`, but uses the specified `code` directly instead of generating one based on the given error message `String`.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwUnless(1024, sender() == self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#require\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native throwUnless(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throw()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrow\n' + + '///\n' + + '@name(throw)\n' + + 'native nativeThrow(code: Int);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwIf()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowif\n' + + '///\n' + + '@name(throw_if)\n' + + 'native nativeThrowIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwUnless()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowunless\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native nativeThrowUnless(code: Int, condition: Bool);\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throw', + loc: { start: 1107, end: 1112 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1113, end: 1117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1113, end: 1122 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 1093, end: 1098 } + } + }, + loc: { start: 1087, end: 1124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwIf', + loc: { start: 2051, end: 2058 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 2059, end: 2063 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2059, end: 2068 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 2070, end: 2079 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2081, end: 2085 } + }, + typeArgs: [], + loc: { start: 2081, end: 2085 } + }, + loc: { start: 2070, end: 2085 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 2034, end: 2042 } + } + }, + loc: { start: 2028, end: 2087 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwUnless', + loc: { start: 3256, end: 3267 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3268, end: 3272 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3268, end: 3277 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3279, end: 3288 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3290, end: 3294 } + }, + typeArgs: [], + loc: { start: 3290, end: 3294 } + }, + loc: { start: 3279, end: 3294 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 3235, end: 3247 } + } + }, + loc: { start: 3229, end: 3296 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrow', + loc: { start: 3534, end: 3545 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3546, end: 3550 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3546, end: 3555 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 3520, end: 3525 } + } + }, + loc: { start: 3514, end: 3557 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowIf', + loc: { start: 3804, end: 3817 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3818, end: 3822 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3818, end: 3827 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3829, end: 3838 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3840, end: 3844 } + }, + typeArgs: [], + loc: { start: 3840, end: 3844 } + }, + loc: { start: 3829, end: 3844 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 3787, end: 3795 } + } + }, + loc: { start: 3781, end: 3846 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowUnless', + loc: { start: 4109, end: 4126 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 4127, end: 4131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4127, end: 4136 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 4138, end: 4147 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4149, end: 4153 } + }, + typeArgs: [], + loc: { start: 4149, end: 4153 } + }, + loc: { start: 4138, end: 4153 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 4088, end: 4100 } + } + }, + loc: { start: 4082, end: 4155 } + } + ] + }, + 'throwIf' => { + kind: 'tact', + path: 'std/internal/debug.tact', + code: '// these are builtin functions, these get special treatment from FunC\n' + + '// hence, no asm here\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Unconditionally throws an exception with an error `code`.\n' + + '///\n' + + '/// Execution of the current context stops, statements after `throw` are not executed, and control is passed to the first `try...catch` block on the call stack. If there is no `try` or `try...catch` block among the calling functions, TVM will terminate the transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun thisWillTerminateAbruptly() {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// fun butThisWont() {\n' + + '/// try {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw)\n' + + 'native throw(code: Int);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` holds, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwIf(1024, sender() != self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_if)\n' + + 'native throwIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` does **not** hold, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// This function is also similar to `require()`, but uses the specified `code` directly instead of generating one based on the given error message `String`.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwUnless(1024, sender() == self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#require\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native throwUnless(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throw()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrow\n' + + '///\n' + + '@name(throw)\n' + + 'native nativeThrow(code: Int);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwIf()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowif\n' + + '///\n' + + '@name(throw_if)\n' + + 'native nativeThrowIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwUnless()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowunless\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native nativeThrowUnless(code: Int, condition: Bool);\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throw', + loc: { start: 1107, end: 1112 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1113, end: 1117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1113, end: 1122 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 1093, end: 1098 } + } + }, + loc: { start: 1087, end: 1124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwIf', + loc: { start: 2051, end: 2058 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 2059, end: 2063 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2059, end: 2068 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 2070, end: 2079 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2081, end: 2085 } + }, + typeArgs: [], + loc: { start: 2081, end: 2085 } + }, + loc: { start: 2070, end: 2085 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 2034, end: 2042 } + } + }, + loc: { start: 2028, end: 2087 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwUnless', + loc: { start: 3256, end: 3267 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3268, end: 3272 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3268, end: 3277 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3279, end: 3288 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3290, end: 3294 } + }, + typeArgs: [], + loc: { start: 3290, end: 3294 } + }, + loc: { start: 3279, end: 3294 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 3235, end: 3247 } + } + }, + loc: { start: 3229, end: 3296 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrow', + loc: { start: 3534, end: 3545 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3546, end: 3550 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3546, end: 3555 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 3520, end: 3525 } + } + }, + loc: { start: 3514, end: 3557 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowIf', + loc: { start: 3804, end: 3817 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3818, end: 3822 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3818, end: 3827 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3829, end: 3838 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3840, end: 3844 } + }, + typeArgs: [], + loc: { start: 3840, end: 3844 } + }, + loc: { start: 3829, end: 3844 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 3787, end: 3795 } + } + }, + loc: { start: 3781, end: 3846 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowUnless', + loc: { start: 4109, end: 4126 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 4127, end: 4131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4127, end: 4136 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 4138, end: 4147 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4149, end: 4153 } + }, + typeArgs: [], + loc: { start: 4149, end: 4153 } + }, + loc: { start: 4138, end: 4153 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 4088, end: 4100 } + } + }, + loc: { start: 4082, end: 4155 } + } + ] + }, + 'throwUnless' => { + kind: 'tact', + path: 'std/internal/debug.tact', + code: '// these are builtin functions, these get special treatment from FunC\n' + + '// hence, no asm here\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Unconditionally throws an exception with an error `code`.\n' + + '///\n' + + '/// Execution of the current context stops, statements after `throw` are not executed, and control is passed to the first `try...catch` block on the call stack. If there is no `try` or `try...catch` block among the calling functions, TVM will terminate the transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun thisWillTerminateAbruptly() {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// fun butThisWont() {\n' + + '/// try {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw)\n' + + 'native throw(code: Int);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` holds, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwIf(1024, sender() != self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_if)\n' + + 'native throwIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` does **not** hold, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// This function is also similar to `require()`, but uses the specified `code` directly instead of generating one based on the given error message `String`.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwUnless(1024, sender() == self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#require\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native throwUnless(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throw()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrow\n' + + '///\n' + + '@name(throw)\n' + + 'native nativeThrow(code: Int);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwIf()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowif\n' + + '///\n' + + '@name(throw_if)\n' + + 'native nativeThrowIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwUnless()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowunless\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native nativeThrowUnless(code: Int, condition: Bool);\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throw', + loc: { start: 1107, end: 1112 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1113, end: 1117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1113, end: 1122 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 1093, end: 1098 } + } + }, + loc: { start: 1087, end: 1124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwIf', + loc: { start: 2051, end: 2058 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 2059, end: 2063 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2059, end: 2068 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 2070, end: 2079 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2081, end: 2085 } + }, + typeArgs: [], + loc: { start: 2081, end: 2085 } + }, + loc: { start: 2070, end: 2085 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 2034, end: 2042 } + } + }, + loc: { start: 2028, end: 2087 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwUnless', + loc: { start: 3256, end: 3267 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3268, end: 3272 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3268, end: 3277 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3279, end: 3288 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3290, end: 3294 } + }, + typeArgs: [], + loc: { start: 3290, end: 3294 } + }, + loc: { start: 3279, end: 3294 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 3235, end: 3247 } + } + }, + loc: { start: 3229, end: 3296 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrow', + loc: { start: 3534, end: 3545 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3546, end: 3550 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3546, end: 3555 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 3520, end: 3525 } + } + }, + loc: { start: 3514, end: 3557 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowIf', + loc: { start: 3804, end: 3817 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3818, end: 3822 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3818, end: 3827 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3829, end: 3838 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3840, end: 3844 } + }, + typeArgs: [], + loc: { start: 3840, end: 3844 } + }, + loc: { start: 3829, end: 3844 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 3787, end: 3795 } + } + }, + loc: { start: 3781, end: 3846 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowUnless', + loc: { start: 4109, end: 4126 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 4127, end: 4131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4127, end: 4136 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 4138, end: 4147 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4149, end: 4153 } + }, + typeArgs: [], + loc: { start: 4149, end: 4153 } + }, + loc: { start: 4138, end: 4153 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 4088, end: 4100 } + } + }, + loc: { start: 4082, end: 4155 } + } + ] + }, + 'nativeThrow' => { + kind: 'tact', + path: 'std/internal/debug.tact', + code: '// these are builtin functions, these get special treatment from FunC\n' + + '// hence, no asm here\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Unconditionally throws an exception with an error `code`.\n' + + '///\n' + + '/// Execution of the current context stops, statements after `throw` are not executed, and control is passed to the first `try...catch` block on the call stack. If there is no `try` or `try...catch` block among the calling functions, TVM will terminate the transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun thisWillTerminateAbruptly() {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// fun butThisWont() {\n' + + '/// try {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw)\n' + + 'native throw(code: Int);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` holds, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwIf(1024, sender() != self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_if)\n' + + 'native throwIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` does **not** hold, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// This function is also similar to `require()`, but uses the specified `code` directly instead of generating one based on the given error message `String`.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwUnless(1024, sender() == self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#require\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native throwUnless(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throw()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrow\n' + + '///\n' + + '@name(throw)\n' + + 'native nativeThrow(code: Int);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwIf()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowif\n' + + '///\n' + + '@name(throw_if)\n' + + 'native nativeThrowIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwUnless()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowunless\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native nativeThrowUnless(code: Int, condition: Bool);\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throw', + loc: { start: 1107, end: 1112 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1113, end: 1117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1113, end: 1122 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 1093, end: 1098 } + } + }, + loc: { start: 1087, end: 1124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwIf', + loc: { start: 2051, end: 2058 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 2059, end: 2063 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2059, end: 2068 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 2070, end: 2079 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2081, end: 2085 } + }, + typeArgs: [], + loc: { start: 2081, end: 2085 } + }, + loc: { start: 2070, end: 2085 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 2034, end: 2042 } + } + }, + loc: { start: 2028, end: 2087 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwUnless', + loc: { start: 3256, end: 3267 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3268, end: 3272 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3268, end: 3277 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3279, end: 3288 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3290, end: 3294 } + }, + typeArgs: [], + loc: { start: 3290, end: 3294 } + }, + loc: { start: 3279, end: 3294 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 3235, end: 3247 } + } + }, + loc: { start: 3229, end: 3296 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrow', + loc: { start: 3534, end: 3545 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3546, end: 3550 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3546, end: 3555 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 3520, end: 3525 } + } + }, + loc: { start: 3514, end: 3557 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowIf', + loc: { start: 3804, end: 3817 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3818, end: 3822 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3818, end: 3827 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3829, end: 3838 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3840, end: 3844 } + }, + typeArgs: [], + loc: { start: 3840, end: 3844 } + }, + loc: { start: 3829, end: 3844 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 3787, end: 3795 } + } + }, + loc: { start: 3781, end: 3846 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowUnless', + loc: { start: 4109, end: 4126 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 4127, end: 4131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4127, end: 4136 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 4138, end: 4147 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4149, end: 4153 } + }, + typeArgs: [], + loc: { start: 4149, end: 4153 } + }, + loc: { start: 4138, end: 4153 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 4088, end: 4100 } + } + }, + loc: { start: 4082, end: 4155 } + } + ] + }, + 'nativeThrowIf' => { + kind: 'tact', + path: 'std/internal/debug.tact', + code: '// these are builtin functions, these get special treatment from FunC\n' + + '// hence, no asm here\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Unconditionally throws an exception with an error `code`.\n' + + '///\n' + + '/// Execution of the current context stops, statements after `throw` are not executed, and control is passed to the first `try...catch` block on the call stack. If there is no `try` or `try...catch` block among the calling functions, TVM will terminate the transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun thisWillTerminateAbruptly() {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// fun butThisWont() {\n' + + '/// try {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw)\n' + + 'native throw(code: Int);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` holds, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwIf(1024, sender() != self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_if)\n' + + 'native throwIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` does **not** hold, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// This function is also similar to `require()`, but uses the specified `code` directly instead of generating one based on the given error message `String`.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwUnless(1024, sender() == self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#require\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native throwUnless(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throw()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrow\n' + + '///\n' + + '@name(throw)\n' + + 'native nativeThrow(code: Int);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwIf()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowif\n' + + '///\n' + + '@name(throw_if)\n' + + 'native nativeThrowIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwUnless()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowunless\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native nativeThrowUnless(code: Int, condition: Bool);\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throw', + loc: { start: 1107, end: 1112 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1113, end: 1117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1113, end: 1122 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 1093, end: 1098 } + } + }, + loc: { start: 1087, end: 1124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwIf', + loc: { start: 2051, end: 2058 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 2059, end: 2063 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2059, end: 2068 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 2070, end: 2079 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2081, end: 2085 } + }, + typeArgs: [], + loc: { start: 2081, end: 2085 } + }, + loc: { start: 2070, end: 2085 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 2034, end: 2042 } + } + }, + loc: { start: 2028, end: 2087 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwUnless', + loc: { start: 3256, end: 3267 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3268, end: 3272 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3268, end: 3277 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3279, end: 3288 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3290, end: 3294 } + }, + typeArgs: [], + loc: { start: 3290, end: 3294 } + }, + loc: { start: 3279, end: 3294 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 3235, end: 3247 } + } + }, + loc: { start: 3229, end: 3296 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrow', + loc: { start: 3534, end: 3545 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3546, end: 3550 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3546, end: 3555 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 3520, end: 3525 } + } + }, + loc: { start: 3514, end: 3557 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowIf', + loc: { start: 3804, end: 3817 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3818, end: 3822 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3818, end: 3827 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3829, end: 3838 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3840, end: 3844 } + }, + typeArgs: [], + loc: { start: 3840, end: 3844 } + }, + loc: { start: 3829, end: 3844 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 3787, end: 3795 } + } + }, + loc: { start: 3781, end: 3846 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowUnless', + loc: { start: 4109, end: 4126 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 4127, end: 4131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4127, end: 4136 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 4138, end: 4147 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4149, end: 4153 } + }, + typeArgs: [], + loc: { start: 4149, end: 4153 } + }, + loc: { start: 4138, end: 4153 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 4088, end: 4100 } + } + }, + loc: { start: 4082, end: 4155 } + } + ] + }, + 'nativeThrowUnless' => { + kind: 'tact', + path: 'std/internal/debug.tact', + code: '// these are builtin functions, these get special treatment from FunC\n' + + '// hence, no asm here\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Unconditionally throws an exception with an error `code`.\n' + + '///\n' + + '/// Execution of the current context stops, statements after `throw` are not executed, and control is passed to the first `try...catch` block on the call stack. If there is no `try` or `try...catch` block among the calling functions, TVM will terminate the transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun thisWillTerminateAbruptly() {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// fun butThisWont() {\n' + + '/// try {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw)\n' + + 'native throw(code: Int);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` holds, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwIf(1024, sender() != self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_if)\n' + + 'native throwIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` does **not** hold, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// This function is also similar to `require()`, but uses the specified `code` directly instead of generating one based on the given error message `String`.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwUnless(1024, sender() == self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#require\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native throwUnless(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throw()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrow\n' + + '///\n' + + '@name(throw)\n' + + 'native nativeThrow(code: Int);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwIf()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowif\n' + + '///\n' + + '@name(throw_if)\n' + + 'native nativeThrowIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwUnless()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowunless\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native nativeThrowUnless(code: Int, condition: Bool);\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throw', + loc: { start: 1107, end: 1112 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1113, end: 1117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1113, end: 1122 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 1093, end: 1098 } + } + }, + loc: { start: 1087, end: 1124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwIf', + loc: { start: 2051, end: 2058 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 2059, end: 2063 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2059, end: 2068 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 2070, end: 2079 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2081, end: 2085 } + }, + typeArgs: [], + loc: { start: 2081, end: 2085 } + }, + loc: { start: 2070, end: 2085 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 2034, end: 2042 } + } + }, + loc: { start: 2028, end: 2087 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwUnless', + loc: { start: 3256, end: 3267 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3268, end: 3272 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3268, end: 3277 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3279, end: 3288 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3290, end: 3294 } + }, + typeArgs: [], + loc: { start: 3290, end: 3294 } + }, + loc: { start: 3279, end: 3294 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 3235, end: 3247 } + } + }, + loc: { start: 3229, end: 3296 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrow', + loc: { start: 3534, end: 3545 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3546, end: 3550 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3546, end: 3555 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 3520, end: 3525 } + } + }, + loc: { start: 3514, end: 3557 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowIf', + loc: { start: 3804, end: 3817 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3818, end: 3822 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3818, end: 3827 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3829, end: 3838 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3840, end: 3844 } + }, + typeArgs: [], + loc: { start: 3840, end: 3844 } + }, + loc: { start: 3829, end: 3844 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 3787, end: 3795 } + } + }, + loc: { start: 3781, end: 3846 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowUnless', + loc: { start: 4109, end: 4126 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 4127, end: 4131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4127, end: 4136 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 4138, end: 4147 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4149, end: 4153 } + }, + typeArgs: [], + loc: { start: 4149, end: 4153 } + }, + loc: { start: 4138, end: 4153 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 4088, end: 4100 } + } + }, + loc: { start: 4082, end: 4155 } + } + ] + }, + 'context' => { + kind: 'tact', + path: 'std/internal/context.tact', + code: '/// Represents the context of the current message.\n' + + 'struct Context {\n' + + ' /// Indicates whether the received message can\n' + + ' /// [bounce back](https://docs.ton.org/v3/documentation/smart-contracts/message-management/non-bounceable-messages).\n' + + ' bounceable: Bool;\n' + + '\n' + + ' /// Internal address of the sender on the TON Blockchain.\n' + + ' sender: Address;\n' + + '\n' + + ' /// Amount of [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin) in the received message.\n' + + ' value: Int;\n' + + '\n' + + ' /// The remainder of the received message as a `Slice`. It follows the [internal message layout]\n' + + ' /// of TON, starting from the destination `Address` (`MsgAddressInt` in [TL-B notation]).\n' + + ' ///\n' + + ' /// [internal message layout]: https://docs.ton.org/develop/smart-contracts/messages#message-layout\n' + + ' /// [TL-B notation]: https://docs.ton.org/develop/data-formats/tl-b-language\n' + + ' raw: Slice;\n' + + '}\n' + + '\n' + + '/// Returns `Context` struct, which consists of:\n' + + '///\n' + + '/// * `bounceable` — Indicates whether the received message can [bounce back].\n' + + '/// * `sender` — Internal address of the sender on the TON blockchain.\n' + + '/// * `value` — Amount of [nanoToncoin] in the received message.\n' + + '/// * `raw` — The remainder of the received message as a `Slice`. It follows the [internal message layout] of TON, starting from the destination `Address` (`MsgAddressInt` in [TL-B notation]).\n' + + '///\n' + + '/// ```tact\n' + + '/// fun test() {\n' + + '/// let ctx: Context = context();\n' + + '/// require(ctx.value != 68 + 1, "Invalid amount of nanoToncoins, bye!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note: If you only need to know who sent the message, use the `sender()` function,\n' + + '/// as it is less gas-consuming.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#context\n' + + '///\n' + + '/// [bounce back]: https://docs.ton.org/v3/documentation/smart-contracts/message-management/non-bounceable-messages\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + '/// [internal message layout]: https://docs.ton.org/develop/smart-contracts/messages#message-layout\n' + + '/// [TL-B notation]: https://docs.ton.org/develop/data-formats/tl-b-language\n' + + '///\n' + + '@name(__tact_context_get)\n' + + 'native context(): Context;\n' + + '\n' + + '/// Returns the `Address` of the sender of the current message.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract MeSee {\n' + + '/// receive() {\n' + + '/// let whoSentMeMessage: Address = sender();\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note: Behavior is undefined for [getter functions], because they cannot have a sender\n' + + '/// nor can they send messages.\n' + + '///\n' + + '/// Tip: To reduce gas usage, prefer using this function over calling `context().sender`\n' + + '/// when you only need to know the sender of the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#sender\n' + + '///\n' + + '/// [getter functions]: https://docs.tact-lang.org/book/contracts#getter-functions\n' + + '///\n' + + '@name(__tact_context_get_sender)\n' + + 'native sender(): Address;\n' + + '\n' + + '/// Extension function for the `Context` structure.\n' + + '///\n' + + '/// Reads forward fee and returns it as `Int` amount of nanoToncoins.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fwdFee: Int = context().readForwardFee();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#contextreadforwardfee\n' + + '/// * https://docs.tact-lang.org/ref/core-gas#getoriginalfwdfee\n' + + '///\n' + + 'asm extends fun readForwardFee(self: Context): Int {\n' + + ' // Only the self.raw (Context.raw) is important,\n' + + ' // so all the other fields and loaded values will be dropped by `BLKDROP2`\n' + + ' //\n' + + ' // Context.raw starts at the dest:MsgAddressInt, following this TL-B scheme:\n' + + ' // int_msg_info$0\n' + + ' // ihr_disabled:Bool\n' + + ' // bounce:Bool\n' + + ' // bounced:Bool\n' + + ' // src:MsgAddress\n' + + ' // dest:MsgAddressInt ← here is the start\n' + + ' // value:CurrencyCollection\n' + + ' // ihr_fee:Grams\n' + + ' // fwd_fee:Grams\n' + + ' // created_lt:uint64\n' + + ' // created_at:uint32\n' + + ' // = CommonMsgInfoRelaxed;\n' + + '\n' + + ' LDMSGADDR // load dest:MsgAddressInt\n' + + ' LDGRAMS // load value:CurrencyCollection\n' + + ' ONE\n' + + ' SDSKIPFIRST // skip extra currency collection\n' + + ' LDGRAMS // load ihr_fee\n' + + " LDGRAMS // load fwd_fee, we'll be using this!\n" + + ' DROP // drop remaining Slice (with created_lt and created_at)\n' + + '\n' + + ' // There are 7 entries on the stack — first 3 fields of Context plus 4 loaded ones.\n' + + " // The topmost is fwd_fee, which is the only one we're after, so let's drop 6 entries below:\n" + + ' 6 1 BLKDROP2 // drop the loaded values as well as the first 3 fields of Context\n' + + '\n' + + ' ZERO // not masterchain\n' + + ' GETORIGINALFWDFEE // floor(fwd_fee * 2^16 / (2^16 - first_frac)), where\n' + + ' // first_frac is a value listed in config param 25\n' + + ' // of the blockchain: https://tonviewer.com/config#25\n' + + ' // this instruction effectively multiplies the fwd_fee by 1.5,\n' + + ' // at least for the current value of first_frac, which is 21845\n' + + '}\n', + imports: [], + items: [ + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 58, end: 65 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounceable', + loc: { start: 244, end: 254 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 256, end: 260 } + }, + typeArgs: [], + loc: { start: 256, end: 260 } + }, + initializer: undefined, + loc: { start: 244, end: 260 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'sender', + loc: { start: 329, end: 335 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 337, end: 344 } + }, + typeArgs: [], + loc: { start: 337, end: 344 } + }, + initializer: undefined, + loc: { start: 329, end: 344 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 462, end: 467 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 469, end: 472 } + }, + loc: { start: 469, end: 472 } + }, + initializer: undefined, + loc: { start: 462, end: 472 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'raw', + loc: { start: 867, end: 870 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 872, end: 877 } }, + loc: { start: 872, end: 877 } + }, + initializer: undefined, + loc: { start: 867, end: 877 } + } + ], + loc: { start: 51, end: 880 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'context', + loc: { start: 2105, end: 2112 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 2116, end: 2123 } + }, + typeArgs: [], + loc: { start: 2116, end: 2123 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_context_get', + loc: { start: 2078, end: 2096 } + } + }, + loc: { start: 2072, end: 2124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sender', + loc: { start: 2802, end: 2808 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2812, end: 2819 } + }, + typeArgs: [], + loc: { start: 2812, end: 2819 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_context_get_sender', + loc: { start: 2768, end: 2793 } + } + }, + loc: { start: 2762, end: 2820 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'readForwardFee', + loc: { start: 3226, end: 3240 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3257, end: 3260 } + }, + loc: { start: 3257, end: 3260 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'LDMSGADDR // load dest:MsgAddressInt\n' + + ' LDGRAMS // load value:CurrencyCollection\n' + + ' ONE\n' + + ' SDSKIPFIRST // skip extra currency collection\n' + + ' LDGRAMS // load ihr_fee\n' + + " LDGRAMS // load fwd_fee, we'll be using this!\n" + + ' DROP // drop remaining Slice (with created_lt and created_at)\n' + + '\n' + + ' // There are 7 entries on the stack — first 3 fields of Context plus 4 loaded ones.\n' + + " // The topmost is fwd_fee, which is the only one we're after, so let's drop 6 entries below:\n" + + ' 6 1 BLKDROP2 // drop the loaded values as well as the first 3 fields of Context\n' + + '\n' + + ' ZERO // not masterchain\n' + + ' GETORIGINALFWDFEE // floor(fwd_fee * 2^16 / (2^16 - first_frac)), where\n' + + ' // first_frac is a value listed in config param 25\n' + + ' // of the blockchain: https://tonviewer.com/config#25\n' + + ' // this instruction effectively multiplies the fwd_fee by 1.5,\n' + + ' // at least for the current value of first_frac, which is 21845' + ] + }, + loc: { start: 3210, end: 4831 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 3247, end: 3254 } + }, + typeArgs: [], + loc: { start: 3247, end: 3254 } + } + } + ] + }, + 'sender' => { + kind: 'tact', + path: 'std/internal/context.tact', + code: '/// Represents the context of the current message.\n' + + 'struct Context {\n' + + ' /// Indicates whether the received message can\n' + + ' /// [bounce back](https://docs.ton.org/v3/documentation/smart-contracts/message-management/non-bounceable-messages).\n' + + ' bounceable: Bool;\n' + + '\n' + + ' /// Internal address of the sender on the TON Blockchain.\n' + + ' sender: Address;\n' + + '\n' + + ' /// Amount of [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin) in the received message.\n' + + ' value: Int;\n' + + '\n' + + ' /// The remainder of the received message as a `Slice`. It follows the [internal message layout]\n' + + ' /// of TON, starting from the destination `Address` (`MsgAddressInt` in [TL-B notation]).\n' + + ' ///\n' + + ' /// [internal message layout]: https://docs.ton.org/develop/smart-contracts/messages#message-layout\n' + + ' /// [TL-B notation]: https://docs.ton.org/develop/data-formats/tl-b-language\n' + + ' raw: Slice;\n' + + '}\n' + + '\n' + + '/// Returns `Context` struct, which consists of:\n' + + '///\n' + + '/// * `bounceable` — Indicates whether the received message can [bounce back].\n' + + '/// * `sender` — Internal address of the sender on the TON blockchain.\n' + + '/// * `value` — Amount of [nanoToncoin] in the received message.\n' + + '/// * `raw` — The remainder of the received message as a `Slice`. It follows the [internal message layout] of TON, starting from the destination `Address` (`MsgAddressInt` in [TL-B notation]).\n' + + '///\n' + + '/// ```tact\n' + + '/// fun test() {\n' + + '/// let ctx: Context = context();\n' + + '/// require(ctx.value != 68 + 1, "Invalid amount of nanoToncoins, bye!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note: If you only need to know who sent the message, use the `sender()` function,\n' + + '/// as it is less gas-consuming.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#context\n' + + '///\n' + + '/// [bounce back]: https://docs.ton.org/v3/documentation/smart-contracts/message-management/non-bounceable-messages\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + '/// [internal message layout]: https://docs.ton.org/develop/smart-contracts/messages#message-layout\n' + + '/// [TL-B notation]: https://docs.ton.org/develop/data-formats/tl-b-language\n' + + '///\n' + + '@name(__tact_context_get)\n' + + 'native context(): Context;\n' + + '\n' + + '/// Returns the `Address` of the sender of the current message.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract MeSee {\n' + + '/// receive() {\n' + + '/// let whoSentMeMessage: Address = sender();\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note: Behavior is undefined for [getter functions], because they cannot have a sender\n' + + '/// nor can they send messages.\n' + + '///\n' + + '/// Tip: To reduce gas usage, prefer using this function over calling `context().sender`\n' + + '/// when you only need to know the sender of the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#sender\n' + + '///\n' + + '/// [getter functions]: https://docs.tact-lang.org/book/contracts#getter-functions\n' + + '///\n' + + '@name(__tact_context_get_sender)\n' + + 'native sender(): Address;\n' + + '\n' + + '/// Extension function for the `Context` structure.\n' + + '///\n' + + '/// Reads forward fee and returns it as `Int` amount of nanoToncoins.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fwdFee: Int = context().readForwardFee();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#contextreadforwardfee\n' + + '/// * https://docs.tact-lang.org/ref/core-gas#getoriginalfwdfee\n' + + '///\n' + + 'asm extends fun readForwardFee(self: Context): Int {\n' + + ' // Only the self.raw (Context.raw) is important,\n' + + ' // so all the other fields and loaded values will be dropped by `BLKDROP2`\n' + + ' //\n' + + ' // Context.raw starts at the dest:MsgAddressInt, following this TL-B scheme:\n' + + ' // int_msg_info$0\n' + + ' // ihr_disabled:Bool\n' + + ' // bounce:Bool\n' + + ' // bounced:Bool\n' + + ' // src:MsgAddress\n' + + ' // dest:MsgAddressInt ← here is the start\n' + + ' // value:CurrencyCollection\n' + + ' // ihr_fee:Grams\n' + + ' // fwd_fee:Grams\n' + + ' // created_lt:uint64\n' + + ' // created_at:uint32\n' + + ' // = CommonMsgInfoRelaxed;\n' + + '\n' + + ' LDMSGADDR // load dest:MsgAddressInt\n' + + ' LDGRAMS // load value:CurrencyCollection\n' + + ' ONE\n' + + ' SDSKIPFIRST // skip extra currency collection\n' + + ' LDGRAMS // load ihr_fee\n' + + " LDGRAMS // load fwd_fee, we'll be using this!\n" + + ' DROP // drop remaining Slice (with created_lt and created_at)\n' + + '\n' + + ' // There are 7 entries on the stack — first 3 fields of Context plus 4 loaded ones.\n' + + " // The topmost is fwd_fee, which is the only one we're after, so let's drop 6 entries below:\n" + + ' 6 1 BLKDROP2 // drop the loaded values as well as the first 3 fields of Context\n' + + '\n' + + ' ZERO // not masterchain\n' + + ' GETORIGINALFWDFEE // floor(fwd_fee * 2^16 / (2^16 - first_frac)), where\n' + + ' // first_frac is a value listed in config param 25\n' + + ' // of the blockchain: https://tonviewer.com/config#25\n' + + ' // this instruction effectively multiplies the fwd_fee by 1.5,\n' + + ' // at least for the current value of first_frac, which is 21845\n' + + '}\n', + imports: [], + items: [ + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 58, end: 65 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounceable', + loc: { start: 244, end: 254 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 256, end: 260 } + }, + typeArgs: [], + loc: { start: 256, end: 260 } + }, + initializer: undefined, + loc: { start: 244, end: 260 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'sender', + loc: { start: 329, end: 335 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 337, end: 344 } + }, + typeArgs: [], + loc: { start: 337, end: 344 } + }, + initializer: undefined, + loc: { start: 329, end: 344 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 462, end: 467 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 469, end: 472 } + }, + loc: { start: 469, end: 472 } + }, + initializer: undefined, + loc: { start: 462, end: 472 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'raw', + loc: { start: 867, end: 870 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 872, end: 877 } }, + loc: { start: 872, end: 877 } + }, + initializer: undefined, + loc: { start: 867, end: 877 } + } + ], + loc: { start: 51, end: 880 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'context', + loc: { start: 2105, end: 2112 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 2116, end: 2123 } + }, + typeArgs: [], + loc: { start: 2116, end: 2123 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_context_get', + loc: { start: 2078, end: 2096 } + } + }, + loc: { start: 2072, end: 2124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sender', + loc: { start: 2802, end: 2808 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2812, end: 2819 } + }, + typeArgs: [], + loc: { start: 2812, end: 2819 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_context_get_sender', + loc: { start: 2768, end: 2793 } + } + }, + loc: { start: 2762, end: 2820 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'readForwardFee', + loc: { start: 3226, end: 3240 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3257, end: 3260 } + }, + loc: { start: 3257, end: 3260 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'LDMSGADDR // load dest:MsgAddressInt\n' + + ' LDGRAMS // load value:CurrencyCollection\n' + + ' ONE\n' + + ' SDSKIPFIRST // skip extra currency collection\n' + + ' LDGRAMS // load ihr_fee\n' + + " LDGRAMS // load fwd_fee, we'll be using this!\n" + + ' DROP // drop remaining Slice (with created_lt and created_at)\n' + + '\n' + + ' // There are 7 entries on the stack — first 3 fields of Context plus 4 loaded ones.\n' + + " // The topmost is fwd_fee, which is the only one we're after, so let's drop 6 entries below:\n" + + ' 6 1 BLKDROP2 // drop the loaded values as well as the first 3 fields of Context\n' + + '\n' + + ' ZERO // not masterchain\n' + + ' GETORIGINALFWDFEE // floor(fwd_fee * 2^16 / (2^16 - first_frac)), where\n' + + ' // first_frac is a value listed in config param 25\n' + + ' // of the blockchain: https://tonviewer.com/config#25\n' + + ' // this instruction effectively multiplies the fwd_fee by 1.5,\n' + + ' // at least for the current value of first_frac, which is 21845' + ] + }, + loc: { start: 3210, end: 4831 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 3247, end: 3254 } + }, + typeArgs: [], + loc: { start: 3247, end: 3254 } + } + } + ] + }, + 'nativeReserve' => { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + 'message' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'send' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'deploy' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'cashback' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'nativeSendMessage' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'sendRawMessage' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'nativeSendMessageReturnForwardFee' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'sendMessageReturnForwardFee' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'emit' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'acceptMessage' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'commit' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'getConfigParam' => { + kind: 'tact', + path: 'std/internal/config.tact', + code: '/// Loads a [configuration parameter] of TON Blockchain by its `id` number.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#getconfigparam\n' + + '///\n' + + '/// [configuration parameter]: https://docs.ton.org/develop/howto/blockchain-configs\n' + + '///\n' + + 'asm fun getConfigParam(id: Int): Cell? { CONFIGOPTPARAM }\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getConfigParam', + loc: { start: 254, end: 268 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 283, end: 284 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { kind: 'SFDefault', loc: { start: 279, end: 283 } }, + loc: { start: 279, end: 283 } + } + ], + loc: { start: 283, end: 284 } + }, + params: [ + { + kind: 'typed_parameter', + name: { kind: 'id', text: 'id', loc: { start: 269, end: 271 } }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 273, end: 276 } + }, + loc: { start: 273, end: 276 } + }, + loc: { start: 269, end: 276 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CONFIGOPTPARAM' ] + }, + loc: { start: 246, end: 303 } + } + ] + }, + 'newAddress' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'parseStdAddress' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'parseVarAddress' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'emptyBasechainAddress' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'newBasechainAddress' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'contractBasechainAddress' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'forceBasechain' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'forceWorkchain' => { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1358, end: 1362 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1363, end: 1374 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { start: 1375, end: 1377 } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1559, end: 1563 } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { start: 1564, end: 1575 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 1576, end: 1577 } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 1014, end: 1019 } }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 2576, end: 2581 } }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 3212, end: 3217 } }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5436, end: 5441 } }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 5969, end: 5974 } }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 6921, end: 6926 } }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 7725, end: 7730 } }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { kind: 'SFDefault', loc: { start: 8619, end: 8624 } }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9269, end: 9276 } }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 9241, end: 9248 } }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { kind: 'null', loc: { start: 9977, end: 9981 } }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { kind: 'SFDefault', loc: { start: 11661, end: 11668 } }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + 'now' => { + kind: 'tact', + path: 'std/internal/time.tact', + code: '/// Global function.\n' + + '///\n' + + '/// Returns the current Unix time.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let timeOffset: Int = now() + 1000; // thousand seconds from now()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#now\n' + + '///\n' + + 'asm fun now(): Int { NOW }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the logical time of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let lt: Int = curLt();\n' + + '/// nativeRandomize(lt); // equivalent to calling nativeRandomizeLt()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '///\n' + + 'asm fun curLt(): Int { LTIME }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the starting logical time of the current block.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let time: Int = blockLt();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#blocklt\n' + + '///\n' + + 'asm fun blockLt(): Int { BLOCKLT }\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'now', loc: { start: 263, end: 266 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 270, end: 273 } + }, + loc: { start: 270, end: 273 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NOW' ] + }, + loc: { start: 255, end: 281 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'curLt', loc: { start: 785, end: 790 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 794, end: 797 } + }, + loc: { start: 794, end: 797 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME' ] + }, + loc: { start: 777, end: 807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'blockLt', + loc: { start: 1108, end: 1115 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BLOCKLT' ] + }, + loc: { start: 1100, end: 1134 } + } + ] + }, + 'curLt' => { + kind: 'tact', + path: 'std/internal/time.tact', + code: '/// Global function.\n' + + '///\n' + + '/// Returns the current Unix time.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let timeOffset: Int = now() + 1000; // thousand seconds from now()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#now\n' + + '///\n' + + 'asm fun now(): Int { NOW }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the logical time of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let lt: Int = curLt();\n' + + '/// nativeRandomize(lt); // equivalent to calling nativeRandomizeLt()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '///\n' + + 'asm fun curLt(): Int { LTIME }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the starting logical time of the current block.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let time: Int = blockLt();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#blocklt\n' + + '///\n' + + 'asm fun blockLt(): Int { BLOCKLT }\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'now', loc: { start: 263, end: 266 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 270, end: 273 } + }, + loc: { start: 270, end: 273 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NOW' ] + }, + loc: { start: 255, end: 281 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'curLt', loc: { start: 785, end: 790 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 794, end: 797 } + }, + loc: { start: 794, end: 797 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME' ] + }, + loc: { start: 777, end: 807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'blockLt', + loc: { start: 1108, end: 1115 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BLOCKLT' ] + }, + loc: { start: 1100, end: 1134 } + } + ] + }, + 'blockLt' => { + kind: 'tact', + path: 'std/internal/time.tact', + code: '/// Global function.\n' + + '///\n' + + '/// Returns the current Unix time.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let timeOffset: Int = now() + 1000; // thousand seconds from now()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#now\n' + + '///\n' + + 'asm fun now(): Int { NOW }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the logical time of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let lt: Int = curLt();\n' + + '/// nativeRandomize(lt); // equivalent to calling nativeRandomizeLt()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '///\n' + + 'asm fun curLt(): Int { LTIME }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the starting logical time of the current block.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let time: Int = blockLt();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#blocklt\n' + + '///\n' + + 'asm fun blockLt(): Int { BLOCKLT }\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'now', loc: { start: 263, end: 266 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 270, end: 273 } + }, + loc: { start: 270, end: 273 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NOW' ] + }, + loc: { start: 255, end: 281 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'curLt', loc: { start: 785, end: 790 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 794, end: 797 } + }, + loc: { start: 794, end: 797 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME' ] + }, + loc: { start: 777, end: 807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'blockLt', + loc: { start: 1108, end: 1115 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BLOCKLT' ] + }, + loc: { start: 1100, end: 1134 } + } + ] + }, + 'f' => { + kind: 'tact', + path: '/home/user/Documents/work/tact5/src/next/example/scope1-b.tact', + code: 'fun f(): Int { return 1; }', + imports: [ + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/stdlib.tact', + code: 'import "./internal/exit-codes";\n' + + 'import "./internal/primitives";\n' + + 'import "./internal/cells";\n' + + 'import "./internal/crypto";\n' + + 'import "./internal/text";\n' + + 'import "./internal/math";\n' + + 'import "./internal/contract";\n' + + 'import "./internal/debug";\n' + + 'import "./internal/context";\n' + + 'import "./internal/reserve";\n' + + 'import "./internal/send";\n' + + 'import "./internal/config";\n' + + 'import "./internal/base";\n' + + 'import "./internal/address";\n' + + 'import "./internal/time";\n', + imports: [ + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + loc: { start: 0, end: 31 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/primitives.tact', + code: '/// `Int` is the primitive 257-bit signed integer type.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/integers\n' + + '///\n' + + 'primitive Int;\n' + + '\n' + + '/// `Bool` is the classical boolean type, which can hold only two values: `true` and `false`.\n' + + '/// It is convenient for boolean and logical operations, as well as for storing flags.\n' + + '///\n' + + '/// There are no implicit type conversions in Tact, so addition `+` of two boolean values is\n' + + '/// not possible. However, many comparison operators are available.\n' + + '///\n' + + '/// Persisting bools to state is very space-efficient, as they only occupy 1 bit.\n' + + '/// Storing 1000 bools in state [costs](https://ton.org/docs/develop/smart-contracts/fees#how-to-calculate-fees)\n' + + '/// about 0.00072 TON per year.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/types#booleans\n' + + '///\n' + + 'primitive Bool;\n' + + '\n' + + '/// `Builder` is a cell manipulation primitive used for cell creation instructions.\n' + + '/// They are immutable just like cells and allow constructing new cells from previously\n' + + '/// stored values and cells.\n' + + '///\n' + + '/// Unlike cells, values of type `Builder` appear only on the [TVM] stack and cannot\n' + + '/// be stored in persistent storage. This means, for example, that persistent storage\n' + + '/// fields with type `Builder` are actually stored as cells under the hood.\n' + + '///\n' + + '/// The `Builder` type represents partially composed cells, for which fast operations\n' + + '/// to append integers, other cells, references to other cells, and many other operations\n' + + '/// are defined.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/cells#builders\n' + + '/// * https://docs.tact-lang.org/ref/core-cells\n' + + '///\n' + + '/// [TVM]: https://docs.ton.org/learn/tvm-instructions/tvm-overview\n' + + 'primitive Builder;\n' + + '\n' + + '/// `Slice` is a cell manipulation primitive used for cell parsing instructions.\n' + + '/// Unlike cells, slices are mutable and allow extraction or loading of data previously\n' + + '/// stored in cells via serialization instructions. Also unlike cells, values of type `Slice`\n' + + '/// appear only on the [TVM] stack and cannot be stored in persistent storage.\n' + + '/// This means, for example, that persistent storage fields with type `Slice` would actually\n' + + '/// be stored as cells under the hood.\n' + + '///\n' + + '/// The `Slice` type represents either the remainder of a partially parsed cell or a value (subcell)\n' + + '/// residing inside such a cell, extracted from it by a parsing instruction.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/cells#slices\n' + + '/// * https://docs.tact-lang.org/ref/core-cells\n' + + '///\n' + + '/// [TVM]: https://docs.ton.org/learn/tvm-instructions/tvm-overview\n' + + 'primitive Slice;\n' + + '\n' + + '/// `Cell` is a primitive and a data structure, which ordinarily consists of up to 1023 continuously\n' + + '/// laid out bits and up to 4 references (refs) to other cells. Circular references are forbidden and\n' + + '/// cannot be created by means of [TVM], which means cells can be viewed as [quadtrees]\n' + + '/// or [directed acyclic graphs (DAGs)][dag] of themselves.\n' + + '///\n' + + '/// Contract code itself is represented by a tree of cells.\n' + + '///\n' + + '/// Cells and cell primitives are bit-oriented, not byte-oriented: [TVM] regards data kept in cells\n' + + '/// as sequences (strings or streams) of up to 1023 bits, not bytes. If necessary, contracts are\n' + + '/// free to use, for example, 21-bit integer fields serialized into [TVM] cells, thus using fewer\n' + + '/// persistent storage bytes to represent the same data.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/cells#cells\n' + + '/// * https://docs.tact-lang.org/ref/core-cells\n' + + '///\n' + + '/// [TVM]: https://docs.ton.org/learn/tvm-instructions/tvm-overview\n' + + '/// [quadtrees]: https://en.wikipedia.org/wiki/Quadtree\n' + + '/// [dag]: https://en.wikipedia.org/wiki/Directed_acyclic_graph\n' + + 'primitive Cell;\n' + + '\n' + + '/// `Address` is a primitive type that represents a [smart contract address] in TON Blockchain.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/types#primitive-types\n' + + '///\n' + + '/// [smart contract address]: https://docs.ton.org/learn/overviews/addresses#address-of-smart-contract\n' + + 'primitive Address;\n' + + '\n' + + '/// `String` is an immutable sequence of characters, which means that once a `String` is created,\n' + + '/// it cannot be changed. Strings are useful for storing text, so they can be converted to a `Cell`\n' + + '/// type to be used as message bodies.\n' + + '///\n' + + '/// To concatenate strings, use a `StringBuilder`.\n' + + '///\n' + + '/// To use `String` literals directly, see: [String literals].\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/types#primitive-types\n' + + '/// * https://docs.tact-lang.org/ref/core-strings\n' + + '///\n' + + '/// [String literals]: https://docs.tact-lang.org/book/expressions#string-literals\n' + + '///\n' + + 'primitive String;\n' + + '\n' + + '/// `StringBuilder` is a primitive used for efficient string concatenation.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/types#primitive-types\n' + + '/// * https://docs.tact-lang.org/ref/core-strings\n' + + '///\n' + + 'primitive StringBuilder;\n', + imports: [], + items: [] + }, + loc: { start: 32, end: 63 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/cells.tact', + code: '//\n' + + '// Builder\n' + + '//\n' + + '\n' + + '/// Creates a new empty `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#begincell\n' + + '///\n' + + 'asm fun beginCell(): Builder { NEWC }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a signed `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 257.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeInt(42, 7);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_int) // special treatment in Func compiler, so not replaced with asm "STIX"\n' + + 'extends native storeInt(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores an unsigned `bits`-bit `value` into the copy of the `Builder` for 0 ≤ `bits` ≤ 256.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeUint(42, 6);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store a negative `value` or provide an insufficient or out-of-bounds `bits` number.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreuint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(store_uint) // special treatment in Func compiler, so not replaced with asm "STUX"\n' + + 'extends native storeUint(self: Builder, value: Int, bits: Int): Builder;\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `Bool` `value` into the copy of the `Builder`.\n' + + '/// Writes 1 as a single bit if `value` is `true`, and writes 0 otherwise.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBool(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBool(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorebool\n' + + '///\n' + + 'asm(value self) extends fun storeBool(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Alias to `Builder.storeBool()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeBit(true); // writes 1\n' + + '/// let buzz: Builder = b.storeBit(false); // writes 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebit\n' + + '///\n' + + 'asm(value self) extends fun storeBit(self: Builder, value: Bool): Builder { 1 STI }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^120 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 4-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^(8 * `l`), followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// This is the most common way of storing nanoToncoins.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeCoins(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeCoins(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Alias to `Builder.storeCoins()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint16(42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorevaruint16\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstorecoins\n' + + '///\n' + + 'asm extends fun storeVarUint16(self: Builder, value: Int): Builder { STVARUINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeCoins()`, but with a different `value` range: from -2^119 to 2^119 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt16(-42);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint16\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt16(self: Builder, value: Int): Builder { STVARINT16 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Stores (serializes) an unsigned `Int` `value` in the range from 0 to 2^248 − 1 inclusive into the copy of the `Builder`. The serialization of `value` consists of a 5-bit unsigned big-endian integer `l`, which is the smallest integer `l` ≥ 0, such that `value` < 2^8 * `l`, followed by an 8 * `l`-bit unsigned big-endian representation of `value`. Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarUint32(420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevaruint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarUint32(self: Builder, value: Int): Builder { STVARUINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Similar to `Builder.storeVarUint32()`, but with a different `value` range: from -2^247 to 2^247 - 1 inclusive.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeVarInt32(-420000);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to store an out-of-bounds `value`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorevarint32\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm extends fun storeVarInt32(self: Builder, value: Int): Builder { STVARINT32 }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a reference `cell` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeRef(emptyCell());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreref\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeRef(self: Builder, cell: Cell): Builder { STREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores a `slice` into a copy of the `Builder`.\n' + + '/// Returns that copy of the `Builder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let s: Slice = emptyCell().asSlice();\n' + + '/// let fizz: Builder = b.storeSlice(s);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#builderstoreslice\n' + + '///\n' + + 'asm extends fun storeSlice(self: Builder, slice: Slice): Builder { STSLICER }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Appends all data from the `other` builder to the copy of the `self` builder. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(op: Int, queryId: Int, payload: Builder) {\n' + + '/// let msgBody = beginCell().storeUint(op, 32).storeUint(queryId, 64);\n' + + '/// if (payload.bits() != 0) {\n' + + '/// msgBody = msgBody.storeBuilder(payload); // assignment is important here\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstorebuilder\n' + + '///\n' + + 'asm extends fun storeBuilder(self: Builder, other: Builder): Builder { STBR }\n' + + '\n' + + '/// Extension function for the `Builder` type. Available since Tact 1.5.0.\n' + + '///\n' + + '/// If the `cell` is not `null`, stores 1 as a single bit and then reference `cell` into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// If the `cell` is `null`, only stores 0 as a single bit into the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// Note that a single `Cell` can contain up to 4 references.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b\n' + + '/// .storeMaybeRef(emptyCell()) // 1, then empty cell\n' + + '/// .storeMaybeRef(null); // 0\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store more than 4 references in a single `Cell`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoremayberef\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm(cell self) extends fun storeMaybeRef(self: Builder, cell: Cell?): Builder { STOPTREF }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Converts a `Builder` into an ordinary `Cell`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let c: Cell = b.endCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/'... 40707 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginCell', + loc: { start: 218, end: 227 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 231, end: 238 } + }, + loc: { start: 231, end: 238 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NEWC' ] + }, + loc: { start: 210, end: 247 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeInt', + loc: { start: 984, end: 992 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 1032, end: 1039 } + }, + loc: { start: 1032, end: 1039 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1008, end: 1013 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1015, end: 1018 } + }, + loc: { start: 1008, end: 1018 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1020, end: 1024 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1026, end: 1029 } + }, + loc: { start: 1020, end: 1029 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_int', + loc: { start: 887, end: 896 } + } + }, + loc: { start: 881, end: 1040 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 999, end: 1006 } + }, + loc: { start: 999, end: 1006 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeUint', + loc: { start: 1817, end: 1826 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 1866, end: 1873 } + }, + loc: { start: 1866, end: 1873 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 1842, end: 1847 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1849, end: 1852 } + }, + loc: { start: 1842, end: 1852 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 1854, end: 1858 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1860, end: 1863 } + }, + loc: { start: 1854, end: 1863 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'store_uint', + loc: { start: 1719, end: 1729 } + } + }, + loc: { start: 1713, end: 1874 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 1833, end: 1840 } + }, + loc: { start: 1833, end: 1840 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBool', + loc: { start: 2420, end: 2429 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 2459, end: 2466 } + }, + loc: { start: 2459, end: 2466 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2445, end: 2450 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2452, end: 2456 } + }, + typeArgs: [], + loc: { start: 2452, end: 2456 } + }, + loc: { start: 2445, end: 2456 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2396, end: 2401 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2402, end: 2406 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2392, end: 2476 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 2436, end: 2443 } + }, + loc: { start: 2436, end: 2443 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBit', + loc: { start: 2902, end: 2910 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 2940, end: 2947 } + }, + loc: { start: 2940, end: 2947 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 2926, end: 2931 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2933, end: 2937 } + }, + typeArgs: [], + loc: { start: 2933, end: 2937 } + }, + loc: { start: 2926, end: 2937 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'value', + loc: { start: 2878, end: 2883 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 2884, end: 2888 } + } + ], + ret: [] + }, + instructions: [ '1 STI' ] + }, + loc: { start: 2874, end: 2957 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 2917, end: 2924 } + }, + loc: { start: 2917, end: 2924 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeCoins', + loc: { start: 3902, end: 3912 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 3941, end: 3948 } + }, + loc: { start: 3941, end: 3948 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 3928, end: 3933 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3935, end: 3938 } + }, + loc: { start: 3928, end: 3938 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 3886, end: 3964 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 3919, end: 3926 } + }, + loc: { start: 3919, end: 3926 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint16', + loc: { start: 4389, end: 4403 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 4432, end: 4439 } + }, + loc: { start: 4432, end: 4439 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 4419, end: 4424 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4426, end: 4429 } + }, + loc: { start: 4419, end: 4429 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT16' ] + }, + loc: { start: 4373, end: 4455 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 4410, end: 4417 } + }, + loc: { start: 4410, end: 4417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt16', + loc: { start: 5096, end: 5109 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 5138, end: 5145 } + }, + loc: { start: 5138, end: 5145 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 5125, end: 5130 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5132, end: 5135 } + }, + loc: { start: 5125, end: 5135 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT16' ] + }, + loc: { start: 5080, end: 5160 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 5116, end: 5123 } + }, + loc: { start: 5116, end: 5123 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarUint32', + loc: { start: 6082, end: 6096 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 6125, end: 6132 } + }, + loc: { start: 6125, end: 6132 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6112, end: 6117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6119, end: 6122 } + }, + loc: { start: 6112, end: 6122 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARUINT32' ] + }, + loc: { start: 6066, end: 6148 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 6103, end: 6110 } + }, + loc: { start: 6103, end: 6110 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeVarInt32', + loc: { start: 6797, end: 6810 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 6839, end: 6846 } + }, + loc: { start: 6839, end: 6846 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'value', + loc: { start: 6826, end: 6831 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6833, end: 6836 } + }, + loc: { start: 6826, end: 6836 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STVARINT32' ] + }, + loc: { start: 6781, end: 6861 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 6817, end: 6824 } + }, + loc: { start: 6817, end: 6824 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeRef', + loc: { start: 7529, end: 7537 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 7566, end: 7573 } + }, + loc: { start: 7566, end: 7573 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 7553, end: 7557 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7559, end: 7563 } + }, + loc: { start: 7553, end: 7563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 7506, end: 7510 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 7511, end: 7515 } + } + ], + ret: [] + }, + instructions: [ 'STREF' ] + }, + loc: { start: 7502, end: 7583 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 7544, end: 7551 } + }, + loc: { start: 7544, end: 7551 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeSlice', + loc: { start: 8005, end: 8015 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8046, end: 8053 } + }, + loc: { start: 8046, end: 8053 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 8031, end: 8036 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8038, end: 8043 } + }, + loc: { start: 8031, end: 8043 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 7989, end: 8066 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8022, end: 8029 } + }, + loc: { start: 8022, end: 8029 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBuilder', + loc: { start: 8633, end: 8645 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8678, end: 8685 } + }, + loc: { start: 8678, end: 8685 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'other', + loc: { start: 8661, end: 8666 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8668, end: 8675 } + }, + loc: { start: 8661, end: 8675 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STBR' ] + }, + loc: { start: 8617, end: 8694 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 8652, end: 8659 } + }, + loc: { start: 8652, end: 8659 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeMaybeRef', + loc: { start: 9622, end: 9635 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 9665, end: 9672 } + }, + loc: { start: 9665, end: 9672 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cell', + loc: { start: 9651, end: 9655 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9661, end: 9662 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9657, end: 9661 } + }, + loc: { start: 9657, end: 9661 } + } + ], + loc: { start: 9661, end: 9662 } + }, + loc: { start: 9651, end: 9662 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'cell', + loc: { start: 9599, end: 9603 } + }, + { + kind: 'id', + text: 'self', + loc: { start: 9604, end: 9608 } + } + ], + ret: [] + }, + instructions: [ 'STOPTREF' ] + }, + loc: { start: 9595, end: 9685 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 9642, end: 9649 } + }, + loc: { start: 9642, end: 9649 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endCell', + loc: { start: 10082, end: 10089 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 10106, end: 10110 } + }, + loc: { start: 10106, end: 10110 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDC' ] + }, + loc: { start: 10066, end: 10119 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 10096, end: 10103 } + }, + loc: { start: 10096, end: 10103 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 10479, end: 10483 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10500, end: 10503 } + }, + loc: { start: 10500, end: 10503 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BREFS' ] + }, + loc: { start: 10463, end: 10513 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 10490, end: 10497 } + }, + loc: { start: 10490, end: 10497 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 10867, end: 10871 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10888, end: 10891 } + }, + loc: { start: 10888, end: 10891 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BBITS' ] + }, + loc: { start: 10851, end: 10901 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 10878, end: 10885 } + }, + loc: { start: 10878, end: 10885 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 11403, end: 11408 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11425, end: 11428 } + }, + loc: { start: 11425, end: 11428 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BDEPTH' ] + }, + loc: { start: 11387, end: 11439 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11415, end: 11422 } + }, + loc: { start: 11415, end: 11422 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginParse', + loc: { start: 11787, end: 11797 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 11811, end: 11816 } + }, + loc: { start: 11811, end: 11816 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CTOS' ] + }, + loc: { start: 11771, end: 11825 } + } + }, + selfType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 11804, end: 11808 } + }, + loc: { start: 11804, end: 11808 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadRef', + loc: { start: 12822, end: 12829 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 12844, end: 12848 } + }, + loc: { start: 12844, end: 12848 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 12797, end: 12798 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 12799, end: 12800 } + } + ] + }, + instructions: [ 'LDREF' ] + }, + loc: { start: 12790, end: 12858 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 12836, end: 12841 } + }, + loc: { start: 12836, end: 12841 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipRef', + loc: { start: 13772, end: 13779 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDREF NIP' ] + }, + loc: { start: 13748, end: 13806 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 13786, end: 13791 } + }, + loc: { start: 13786, end: 13791 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadRef', + loc: { start: 14937, end: 14947 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 14962, end: 14966 } + }, + loc: { start: 14962, end: 14966 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDREF' ] + }, + loc: { start: 14921, end: 14977 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 14954, end: 14959 } + }, + loc: { start: 14954, end: 14959 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadMaybeRef', + loc: { start: 16024, end: 16036 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 16055, end: 16056 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16051, end: 16055 } + }, + loc: { start: 16051, end: 16055 } + } + ], + loc: { start: 16055, end: 16056 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15999, end: 16000 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 16001, end: 16002 } + } + ] + }, + instructions: [ 'LDOPTREF' ] + }, + loc: { start: 15992, end: 16069 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 16043, end: 16048 } + }, + loc: { start: 16043, end: 16048 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipMaybeRef', + loc: { start: 17041, end: 17053 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDOPTREF NIP' ] + }, + loc: { start: 17017, end: 17083 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 17060, end: 17065 } + }, + loc: { start: 17060, end: 17065 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadMaybeRef', + loc: { start: 18449, end: 18464 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 18483, end: 18484 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 18479, end: 18483 } + }, + loc: { start: 18479, end: 18483 } + } + ], + loc: { start: 18483, end: 18484 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'PLDOPTREF' ] + }, + loc: { start: 18433, end: 18498 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 18471, end: 18476 } + }, + loc: { start: 18471, end: 18476 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBits', + loc: { start: 19377, end: 19385 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 19408, end: 19413 } + }, + loc: { start: 19408, end: 19413 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 19399, end: 19400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19402, end: 19405 } + }, + loc: { start: 19399, end: 19405 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_bits', + loc: { start: 19268, end: 19277 } + } + }, + loc: { start: 19262, end: 19414 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 19392, end: 19397 } + }, + loc: { start: 19392, end: 19397 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadBits', + loc: { start: 20333, end: 20344 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 20367, end: 20372 } + }, + loc: { start: 20367, end: 20372 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 20358, end: 20359 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20361, end: 20364 } + }, + loc: { start: 20358, end: 20364 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_bits', + loc: { start: 20228, end: 20240 } + } + }, + loc: { start: 20222, end: 20373 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 20351, end: 20356 } + }, + loc: { start: 20351, end: 20356 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadInt', + loc: { start: 21236, end: 21243 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21266, end: 21269 } + }, + loc: { start: 21266, end: 21269 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 21257, end: 21258 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21260, end: 21263 } + }, + loc: { start: 21257, end: 21263 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_int', + loc: { start: 21132, end: 21140 } + } + }, + loc: { start: 21126, end: 21270 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 21250, end: 21255 } + }, + loc: { start: 21250, end: 21255 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadInt', + loc: { start: 22164, end: 22174 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22197, end: 22200 } + }, + loc: { start: 22197, end: 22200 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 22188, end: 22189 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22191, end: 22194 } + }, + loc: { start: 22188, end: 22194 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_int', + loc: { start: 22064, end: 22075 } + } + }, + loc: { start: 22058, end: 22201 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 22181, end: 22186 } + }, + loc: { start: 22181, end: 22186 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadUint', + loc: { start: 23071, end: 23079 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23102, end: 23105 } + }, + loc: { start: 23102, end: 23105 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 23093, end: 23094 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23096, end: 23099 } + }, + loc: { start: 23093, end: 23099 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'load_uint', + loc: { start: 22966, end: 22975 } + } + }, + loc: { start: 22960, end: 23106 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 23086, end: 23091 } + }, + loc: { start: 23086, end: 23091 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'preloadUint', + loc: { start: 24007, end: 24018 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24041, end: 24044 } + }, + loc: { start: 24041, end: 24044 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 24032, end: 24033 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24035, end: 24038 } + }, + loc: { start: 24032, end: 24038 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'preload_uint', + loc: { start: 23906, end: 23918 } + } + }, + loc: { start: 23900, end: 24045 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 24025, end: 24030 } + }, + loc: { start: 24025, end: 24030 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBool', + loc: { start: 24834, end: 24842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 24857, end: 24861 } + }, + typeArgs: [], + loc: { start: 24857, end: 24861 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 24809, end: 24810 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 24811, end: 24812 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 24802, end: 24871 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 24849, end: 24854 } + }, + loc: { start: 24849, end: 24854 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBool', + loc: { start: 25769, end: 25777 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '1 LDI NIP' ] + }, + loc: { start: 25745, end: 25804 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 25784, end: 25789 } + }, + loc: { start: 25784, end: 25789 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadBit', + loc: { start: 26558, end: 26565 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 26580, end: 26584 } + }, + typeArgs: [], + loc: { start: 26580, end: 26584 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 26533, end: 26534 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 26535, end: 26536 } + } + ] + }, + instructions: [ '1 LDI' ] + }, + loc: { start: 26526, end: 26594 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 26572, end: 26577 } + }, + loc: { start: 26572, end: 26577 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadCoins', + loc: { start: 27454, end: 27463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 27478, end: 27481 } + }, + loc: { start: 27478, end: 27481 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 27429, end: 27430 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 27431, end: 27432 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 27422, end: 27497 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 27470, end: 27475 } + }, + loc: { start: 27470, end: 27475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipCoins', + loc: { start: 28454, end: 28463 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 28430, end: 28496 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 28470, end: 28475 } + }, + loc: { start: 28470, end: 28475 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint16', + loc: { start: 29318, end: 29331 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 29346, end: 29349 } + }, + loc: { start: 29346, end: 29349 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 29293, end: 29294 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 29295, end: 29296 } + } + ] + }, + instructions: [ 'LDVARUINT16' ] + }, + loc: { start: 29286, end: 29365 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 29338, end: 29343 } + }, + loc: { start: 29338, end: 29343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint16', + loc: { start: 30263, end: 30276 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT16 NIP' ] + }, + loc: { start: 30239, end: 30309 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 30283, end: 30288 } + }, + loc: { start: 30283, end: 30288 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt16', + loc: { start: 31141, end: 31153 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 31168, end: 31171 } + }, + loc: { start: 31168, end: 31171 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 31116, end: 31117 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 31118, end: 31119 } + } + ] + }, + instructions: [ 'LDVARINT16' ] + }, + loc: { start: 31109, end: 31186 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 31160, end: 31165 } + }, + loc: { start: 31160, end: 31165 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt16', + loc: { start: 32093, end: 32105 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT16 NIP' ] + }, + loc: { start: 32069, end: 32137 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 32112, end: 32117 } + }, + loc: { start: 32112, end: 32117 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarUint32', + loc: { start: 32987, end: 33000 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 33015, end: 33018 } + }, + loc: { start: 33015, end: 33018 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 32962, end: 32963 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 32964, end: 32965 } + } + ] + }, + instructions: [ 'LDVARUINT32' ] + }, + loc: { start: 32955, end: 33034 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 33007, end: 33012 } + }, + loc: { start: 33007, end: 33012 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarUint32', + loc: { start: 34007, end: 34020 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARUINT32 NIP' ] + }, + loc: { start: 33983, end: 34053 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 34027, end: 34032 } + }, + loc: { start: 34027, end: 34032 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadVarInt32', + loc: { start: 34897, end: 34909 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 34924, end: 34927 } + }, + loc: { start: 34924, end: 34927 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 34872, end: 34873 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 34874, end: 34875 } + } + ] + }, + instructions: [ 'LDVARINT32' ] + }, + loc: { start: 34865, end: 34942 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 34916, end: 34921 } + }, + loc: { start: 34916, end: 34921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipVarInt32', + loc: { start: 35854, end: 35866 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDVARINT32 NIP' ] + }, + loc: { start: 35830, end: 35898 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 35873, end: 35878 } + }, + loc: { start: 35873, end: 35878 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipBits', + loc: { start: 36746, end: 36754 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'l', + loc: { start: 36768, end: 36769 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36771, end: 36774 } + }, + loc: { start: 36768, end: 36774 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPFIRST' ] + }, + loc: { start: 36722, end: 36791 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 36761, end: 36766 } + }, + loc: { start: 36761, end: 36766 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'endParse', + loc: { start: 37397, end: 37405 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ENDS' ] + }, + loc: { start: 37381, end: 37427 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 37412, end: 37417 } + }, + loc: { start: 37412, end: 37417 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipLastBits', + loc: { start: 38319, end: 38331 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 38356, end: 38361 } + }, + loc: { start: 38356, end: 38361 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 38345, end: 38348 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38350, end: 38353 } + }, + loc: { start: 38345, end: 38353 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDSKIPLAST' ] + }, + loc: { start: 38303, end: 38376 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 38338, end: 38343 } + }, + loc: { start: 38338, end: 38343 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'firstBits', + loc: { start: 39373, end: 39382 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 39407, end: 39412 } + }, + loc: { start: 39407, end: 39412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 39396, end: 39399 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39401, end: 39404 } + }, + loc: { start: 39396, end: 39404 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTFIRST' ] + }, + loc: { start: 39357, end: 39427 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 39389, end: 39394 } + }, + loc: { start: 39389, end: 39394 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'lastBits', + loc: { start: 40218, end: 40226 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 40251, end: 40256 } + }, + loc: { start: 40251, end: 40256 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'len', + loc: { start: 40240, end: 40243 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40245, end: 40248 } + }, + loc: { start: 40240, end: 40248 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDCUTLAST' ] + }, + loc: { start: 40202, end: 40270 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 40233, end: 40238 } + }, + loc: { start: 40233, end: 40238 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 40758, end: 40763 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 40778, end: 40781 } + }, + loc: { start: 40778, end: 40781 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEPTH' ] + }, + loc: { start: 40742, end: 40792 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 40770, end: 40775 } + }, + loc: { start: 40770, end: 40775 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refs', + loc: { start: 41166, end: 41170 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41185, end: 41188 } + }, + loc: { start: 41185, end: 41188 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREFS' ] + }, + loc: { start: 41150, end: 41198 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 41177, end: 41182 } + }, + loc: { start: 41177, end: 41182 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'bits', + loc: { start: 41550, end: 41554 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 41569, end: 41572 } + }, + loc: { start: 41569, end: 41572 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SBITS' ] + }, + loc: { start: 41534, end: 41582 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 41561, end: 41566 } + }, + loc: { start: 41561, end: 41566 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'empty', + loc: { start: 42117, end: 42122 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42137, end: 42141 } + }, + typeArgs: [], + loc: { start: 42137, end: 42141 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SEMPTY' ] + }, + loc: { start: 42101, end: 42152 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 42129, end: 42134 } + }, + loc: { start: 42129, end: 42134 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'dataEmpty', + loc: { start: 42682, end: 42691 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 42706, end: 42710 } + }, + typeArgs: [], + loc: { start: 42706, end: 42710 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDEMPTY' ] + }, + loc: { start: 42666, end: 42722 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 42698, end: 42703 } + }, + loc: { start: 42698, end: 42703 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'refsEmpty', + loc: { start: 43231, end: 43240 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 43255, end: 43259 } + }, + typeArgs: [], + loc: { start: 43255, end: 43259 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SREMPTY' ] + }, + loc: { start: 43215, end: 43271 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 43247, end: 43252 } + }, + loc: { start: 43247, end: 43252 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 43671, end: 43678 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 43695, end: 43700 } + }, + loc: { start: 43695, end: 43700 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 43714, end: 43718 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 43719, end: 43726 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43728 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 43729, end: 43739 } + }, + typeArgs: [], + args: [], + loc: { start: 43714, end: 43741 } + }, + loc: { start: 43707, end: 43742 } + } + ] + }, + loc: { start: 43652, end: 43744 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 43685, end: 43692 } + }, + loc: { start: 43685, end: 43692 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 44098, end: 44105 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 44119, end: 44124 } + }, + loc: { start: 44119, end: 44124 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 44138, end: 44142 } + }, + method: { + kind: 'id', + text: 'beginParse', + loc: { start: 44143, end: 44153 } + }, + typeArgs: [], + args: [], + loc: { start: 44138, end: 44155 } + }, + loc: { start: 44131, end: 44156 } + } + ] + }, + loc: { start: 44079, end: 44158 } + } + }, + selfType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 44112, end: 44116 } + }, + loc: { start: 44112, end: 44116 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 44714, end: 44720 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 44735, end: 44739 } + }, + loc: { start: 44735, end: 44739 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 44753, end: 44762 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44764 } + }, + method: { + kind: 'id', + text: 'storeSlice', + loc: { start: 44774, end: 44784 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 44785, end: 44789 } + } + ], + loc: { start: 44753, end: 44790 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 44800, end: 44807 } + }, + typeArgs: [], + args: [], + loc: { start: 44753, end: 44809 } + }, + loc: { start: 44746, end: 44810 } + } + ] + }, + loc: { start: 44695, end: 44812 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 44727, end: 44732 } + }, + loc: { start: 44727, end: 44732 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'asCell', + loc: { start: 45173, end: 45179 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 45196, end: 45200 } + }, + loc: { start: 45196, end: 45200 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 45214, end: 45218 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 45219, end: 45226 } + }, + typeArgs: [], + args: [], + loc: { start: 45214, end: 45228 } + }, + loc: { start: 45207, end: 45229 } + } + ] + }, + loc: { start: 45154, end: 45231 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 45186, end: 45193 } + }, + loc: { start: 45186, end: 45193 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptyCell', + loc: { start: 45592, end: 45601 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 45605, end: 45609 } + }, + loc: { start: 45605, end: 45609 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + ' PUSHREF // Pure Fift: "" turns it into a cell at compile time' + ] + }, + loc: { start: 45584, end: 45711 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'emptySlice', + loc: { start: 46077, end: 46087 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 46091, end: 46096 } + }, + loc: { start: 46091, end: 46096 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'b{} PUSHSLICE' ] + }, + loc: { start: 46069, end: 46118 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 46431, end: 46439 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'cells', + loc: { start: 46516, end: 46521 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46523, end: 46526 } + }, + loc: { start: 46523, end: 46526 } + }, + initializer: undefined, + loc: { start: 46516, end: 46526 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bits', + loc: { start: 46615, end: 46619 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46621, end: 46624 } + }, + loc: { start: 46621, end: 46624 } + }, + initializer: undefined, + loc: { start: 46615, end: 46624 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'refs', + loc: { start: 46713, end: 46717 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 46719, end: 46722 } + }, + loc: { start: 46719, end: 46722 } + }, + initializer: undefined, + loc: { start: 46713, end: 46722 } + } + ], + loc: { start: 46424, end: 46725 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 48450, end: 48465 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 48495, end: 48503 } + }, + typeArgs: [], + loc: { start: 48495, end: 48503 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 48479, end: 48487 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48489, end: 48492 } + }, + loc: { start: 48479, end: 48492 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDATASIZE' ] + }, + loc: { start: 48434, end: 48517 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 48476, end: 48477 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 48472, end: 48476 } + }, + loc: { start: 48472, end: 48476 } + } + ], + loc: { start: 48476, end: 48477 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'computeDataSize', + loc: { start: 50094, end: 50109 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DataSize', + loc: { start: 50139, end: 50147 } + }, + typeArgs: [], + loc: { start: 50139, end: 50147 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'maxCells', + loc: { start: 50123, end: 50131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50133, end: 50136 } + }, + loc: { start: 50123, end: 50136 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SDATASIZE' ] + }, + loc: { start: 50078, end: 50161 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 50116, end: 50121 } + }, + loc: { start: 50116, end: 50121 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'depth', + loc: { start: 50672, end: 50677 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 50692, end: 50695 } + }, + loc: { start: 50692, end: 50695 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CDEPTH' ] + }, + loc: { start: 50656, end: 50706 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 50688, end: 50689 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 50684, end: 50688 } + }, + loc: { start: 50684, end: 50688 } + } + ], + loc: { start: 50688, end: 50689 } + } + } + ] + }, + loc: { start: 64, end: 90 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/crypto.tact', + code: '/// Extension function for the `Cell` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Cell` representation][std-representation] of the given `Cell`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let c: Cell = emptyCell();\n' + + '/// let fizz: Int = c.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#cellhash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Cell): Int { HASHCU }\n' + + '\n' + + '/// Extension function for the `Slice` type.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the [SHA-256] hash of the\n' + + '/// [standard `Slice` representation][std-representation] of the given `Slice`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().asSlice();\n' + + '/// let fizz: Int = s.hash();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehash\n' + + '///\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '/// [std-representation]: https://docs.tact-lang.org/book/cells#cells-representation\n' + + '///\n' + + 'asm extends fun hash(self: Slice): Int { HASHSU }\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `Slice`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes the data of the given `Slice`, i.e. up to 1023 bits, ignoring the refs.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// // Base64-encoded BoC with "Hello, World!"\n' + + '/// let short: Slice = slice("te6cckEBAQEADgAAGEhlbGxvIHdvcmxkIXgtxbw=");\n' + + '///\n' + + "/// // It's enough to only take the hash of the data\n" + + '/// sha256(short) == short.hashData(); // true\n' + + '///\n' + + '/// // But if we construct a slice larger than 1023 bits with all refs combined,\n' + + "/// // we must use sha256() or we'll get skewed results or even collisions\n" + + '///\n' + + '/// let tmp: Builder = beginCell();\n' + + '/// repeat (127) { tmp = tmp.storeUint(69, 8) } // storing 127 bytes\n' + + '/// let ref: Cell = beginCell().storeUint(33, 8).endCell();\n' + + '/// let long: Slice = tmp.storeRef(ref).asSlice(); // plus a ref with a single byte\n' + + '///\n' + + "/// // Hashing just the data bits in the current slice isn't enough\n" + + '/// sha256(long) == long.hashData(); // false!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `Slice` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#slicehashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: Slice): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Extension function for the `String` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Calculates and returns an `Int` value of the SHA-256 hash of the data bits from the given `String`, which should have a number of bits divisible by 8.\n' + + '///\n' + + '/// Unlike `sha256()`, this function is gas-efficient and **only** hashes up to 127 bytes of the given string. Using longer strings would cause collisions if their first 127 bytes are the same.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let roll: Int = "Never gonna give you up!".hashData(); // just the hash of the data\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when attempting to specify a `String` with number of bits **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringhashdata\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends fun hashData(self: String): Int { ONE HASHEXT_SHA256 }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the 256-bit unsigned `Int` `hash` using a `publicKey`,\n' + + '/// represented by a 256-bit unsigned `Int`. The signature must contain at least 512 bits of data, but\n' + + '/// only the first 512 bits are used.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// message ExtMsg {\n' + + '/// signature: Slice;\n' + + '/// data: Cell;\n' + + '/// }\n' + + '///\n' + + '/// contract Showcase {\n' + + '/// /// Persistent state variables\n' + + '/// pub: Int as uint256; // public key as a 256-bit unsigned Int\n' + + '///\n' + + '/// /// Constructor function init(), where all variables are initialized\n' + + '/// init(pub: Int) {\n' + + '/// self.pub = pub; // storing the public key upon contract initialization\n' + + '/// }\n' + + '///\n' + + '/// /// External message receiver, which accepts message ExtMsg\n' + + '/// external(msg: ExtMsg) {\n' + + '/// let hash: Int = beginCell().storeRef(msg.data).endCell().hash();\n' + + '/// let check: Bool = checkSignature(hash, msg.signature, self.pub);\n' + + '/// // ---- ------------- --------\n' + + '/// // ↑ ↑ ↑\n' + + '/// // | | publicKey stored in our contract\n' + + '/// // | signature obtained from the received message\n' + + '/// // hash calculated using the data from the received message\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checksignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'asm fun checkSignature(hash: Int, signature: Slice, publicKey: Int): Bool { CHKSIGNU }\n' + + '\n' + + '/// Checks the [Ed25519] `signature` of the `data` using a `publicKey`, similar to `checkSignature()`.\n' + + '/// Verification itself is done indirectly on a [SHA-256] hash of the `data`.\n' + + '///\n' + + '/// Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let data: Slice = someData;\n' + + '/// let signature: Slice = someSignature;\n' + + '/// let publicKey: Int = 42;\n' + + '///\n' + + '/// let check: Bool = checkDataSignature(data, signature, publicKey);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// NOTE: The first 10 calls of this function are very cheap regarding gas usage. However,\n' + + '/// the 11th call and onward consume more than 4 thousand gas units.\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 9: [Cell underflow] — Thrown when the bit length of `data` is **not** divisible by 8.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#checkdatasignature\n' + + '///\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '/// [SHA-256]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard\n' + + '///\n' + + 'asm fun checkDataSignature(data: Slice, signature: Slice, publicKey: Int): Bool { CHKSIGNS }\n' + + '\n' + + '/// A struct that contains a 512-bit [Ed25519] signature and the data it signs.\n' + + '///\n' + + '/// ```tact\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundle\n' + + '/// * https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'struct SignedBundle {\n' + + ' /// A 512-bit Ed25519 signature of the `signedData`.\n' + + ' signature: Slice as bytes64;\n' + + '\n' + + ' /// The remaining non-serialized data of the enclosing struct or message struct,\n' + + ' /// which was used to obtain the 512-bit Ed25519 `signature`.\n' + + ' signedData: Slice as remaining;\n' + + '}\n' + + '\n' + + '/// Extension function for the `SignedBundle` struct. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Checks whether `self.signedData` was signed by the 512-bit [Ed25519] signature `self.signature`,\n' + + '/// using the given `publicKey`. Returns `true` if the signature is valid, `false` otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example(publicKey: Int as uint256) {\n' + + '/// external(msg: MessageWithSignedData) {\n' + + '/// // Checks that the signature of the SignedBundle from the incoming external\n' + + "/// // message wasn't forged and made by the owner of this self.publicKey with\n" + + '/// // its respective private key managed elsewhere.\n' + + '/// throwUnless(35, msg.bundle.verifySignature(self.publicKey));\n' + + '///\n' + + '/// // ...rest of the checks and code...\n' + + '/// }\n' + + '/// }\n' + + '///\n' + + '/// message MessageWithSignedData {\n' + + '/// // The `bundle.signature` contains the 512-bit Ed25519 signature\n' + + '/// // of the remaining data fields of this message struct,\n' + + '/// // while `bundle.signedData` references those data fields.\n' + + '/// // In this case, the fields are `walletId` and `seqno`.\n' + + '/// bundle: SignedBundle;\n' + + '///\n' + + '/// // These fields are common to external messages to user wallets.\n' + + '/// walletId: Int as int32;\n' + + '/// seqno: Int as uint32;\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-crypto#signedbundleverifysignature\n' + + '///\n' + + '/// [Ed25519]: https://en.wikipedia.org/wiki/EdDSA#Ed25519\n' + + '///\n' + + 'inline extends fun verifySignature(self: SignedBundle, publicKey: Int): Bool {\n' + + ' return checkSignature(self.signedData.hash(), self.signature, publicKey);\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.6.\n' + + '///\n' + + '/// Computes and returns the Ethereum-compatible [Keccak-256] hash as a 256-bit unsigned `Int` from the passed `Slice` `data`.\n' + + '///\n' + + '/// The `data` slice should have a number of bits divisible by 8 and no more than a single reference per cell, because only the first reference of each nested cell will be taken into account.\n' + + '///\n' + + '/// #### Usage\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Examples() {\n' + + '/// receive(rawMsg: Slice) {\n' + + '/// // Hash incoming messa'... 1135 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 554, end: 558 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 572, end: 575 } + }, + loc: { start: 572, end: 575 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHCU' ] + }, + loc: { start: 538, end: 586 } + } + }, + selfType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 565, end: 569 } + }, + loc: { start: 565, end: 569 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hash', + loc: { start: 1232, end: 1236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1251, end: 1254 } + }, + loc: { start: 1251, end: 1254 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'HASHSU' ] + }, + loc: { start: 1216, end: 1265 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 1243, end: 1248 } + }, + loc: { start: 1243, end: 1248 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 2808, end: 2816 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2831, end: 2834 } + }, + loc: { start: 2831, end: 2834 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 2792, end: 2857 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 2823, end: 2828 } + }, + loc: { start: 2823, end: 2828 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'hashData', + loc: { start: 3740, end: 3748 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3764, end: 3767 } + }, + loc: { start: 3764, end: 3767 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ONE HASHEXT_SHA256' ] + }, + loc: { start: 3724, end: 3790 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3755, end: 3761 } + }, + typeArgs: [], + loc: { start: 3755, end: 3761 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkSignature', + loc: { start: 5592, end: 5606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 5653, end: 5657 } + }, + typeArgs: [], + loc: { start: 5653, end: 5657 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 5607, end: 5611 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5613, end: 5616 } + }, + loc: { start: 5607, end: 5616 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 5618, end: 5627 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 5629, end: 5634 } + }, + loc: { start: 5629, end: 5634 } + }, + loc: { start: 5618, end: 5634 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 5636, end: 5645 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5647, end: 5650 } + }, + loc: { start: 5636, end: 5650 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNU' ] + }, + loc: { start: 5584, end: 5670 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'checkDataSignature', + loc: { start: 6731, end: 6749 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 6798, end: 6802 } + }, + typeArgs: [], + loc: { start: 6798, end: 6802 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 6750, end: 6754 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 6756, end: 6761 } + }, + loc: { start: 6756, end: 6761 } + }, + loc: { start: 6750, end: 6761 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'signature', + loc: { start: 6763, end: 6772 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 6774, end: 6779 } + }, + loc: { start: 6774, end: 6779 } + }, + loc: { start: 6763, end: 6779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 6781, end: 6790 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6792, end: 6795 } + }, + loc: { start: 6781, end: 6795 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CHKSIGNS' ] + }, + loc: { start: 6723, end: 6815 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 7626, end: 7638 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signature', + loc: { start: 7702, end: 7711 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFBits', + bits: 512, + loc: { start: 7713, end: 7729 } + }, + loc: { start: 7713, end: 7718 } + }, + initializer: undefined, + loc: { start: 7702, end: 7729 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'signedData', + loc: { start: 7887, end: 7897 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFRemaining', + loc: { start: 7899, end: 7917 } + }, + loc: { start: 7899, end: 7904 } + }, + initializer: undefined, + loc: { start: 7887, end: 7917 } + } + ], + loc: { start: 7619, end: 7920 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'verifySignature', + loc: { start: 9355, end: 9370 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9408, end: 9412 } + }, + typeArgs: [], + loc: { start: 9408, end: 9412 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'publicKey', + loc: { start: 9391, end: 9400 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9402, end: 9405 } + }, + loc: { start: 9391, end: 9405 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'checkSignature', + loc: { start: 9426, end: 9440 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9441, end: 9445 } + }, + field: { + kind: 'id', + text: 'signedData', + loc: { start: 9446, end: 9456 } + }, + loc: { start: 9441, end: 9456 } + }, + method: { + kind: 'id', + text: 'hash', + loc: { start: 9457, end: 9461 } + }, + typeArgs: [], + args: [], + loc: { start: 9441, end: 9463 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 9465, end: 9469 } + }, + field: { + kind: 'id', + text: 'signature', + loc: { start: 9470, end: 9479 } + }, + loc: { start: 9465, end: 9479 } + }, + { + kind: 'var', + name: 'publicKey', + loc: { start: 9481, end: 9490 } + } + ], + loc: { start: 9426, end: 9491 } + }, + loc: { start: 9419, end: 9492 } + } + ] + }, + loc: { start: 9336, end: 9494 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SignedBundle', + loc: { start: 9377, end: 9389 } + }, + typeArgs: [], + loc: { start: 9377, end: 9389 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'keccak256', + loc: { start: 10942, end: 10951 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10966, end: 10969 } + }, + loc: { start: 10966, end: 10969 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 10952, end: 10956 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10958, end: 10963 } + }, + loc: { start: 10952, end: 10963 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' <{ DUP SREFS }> PUSHCONT\n' + + ' <{ LDREFRTOS }> PUSHCONT\n' + + ' WHILE\n' + + ' DEPTH\n' + + ' HASHEXT_KECCAK256\n' + + ' }> PUSHCONT\n' + + ' 1 1 CALLXARGS' + ] + }, + loc: { start: 10934, end: 11134 } + } + ] + }, + loc: { start: 91, end: 118 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/text.tact', + code: '//\n' + + '// String builder\n' + + '//\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstring\n' + + '///\n' + + '@name(__tact_string_builder_start_string)\n' + + 'native beginString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a comment string, which prefixes\n' + + '/// the resulting `String` with four null bytes. This format is used for passing text comments\n' + + '/// as message bodies.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginComment();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begincomment\n' + + '///\n' + + '@name(__tact_string_builder_start_comment)\n' + + 'native beginComment(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns an empty `StringBuilder` for building a tail string, which prefixes\n' + + '/// the resulting `String` with a single null byte. This format is used in various standards\n' + + '/// such as NFT or Jetton.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginTailString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#begintailstring\n' + + '///\n' + + '@name(__tact_string_builder_start_tail_string)\n' + + 'native beginTailString(): StringBuilder;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates and returns a new `StringBuilder` from an existing `StringBuilder` `b`. Useful when\n' + + '/// you need to serialize an existing `String` to a `Cell` along with other data.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example(): String {\n' + + '/// let fizz: StringBuilder = beginStringFromBuilder(beginString());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#beginstringfrombuilder\n' + + '///\n' + + '@name(__tact_string_builder_start)\n' + + 'native beginStringFromBuilder(b: Builder): StringBuilder;\n' + + '\n' + + '/// Extension mutation function for the `StringBuilder` type.\n' + + '///\n' + + '/// Appends a `String` `s` to the `StringBuilder`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// fizz.append("oh");\n' + + '/// fizz.append("my");\n' + + '/// fizz.append("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderappend\n' + + '///\n' + + '@name(__tact_string_builder_append)\n' + + 'extends mutates native append(self: StringBuilder, s: String);\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a new `StringBuilder` after concatenating it with a `String` `s`. It can be chained,\n' + + '/// unlike `StringBuilder.append()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString()\n' + + '/// .concat("oh")\n' + + '/// .concat("my")\n' + + '/// .concat("Tact!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuilderconcat\n' + + '///\n' + + '@name(__tact_string_builder_append_not_mut)\n' + + 'extends native concat(self: StringBuilder, s: String): StringBuilder;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: Cell = fizz.toCell();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertocell\n' + + '///\n' + + '@name(__tact_string_builder_end)\n' + + 'extends native toCell(self: StringBuilder): Cell;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns a built `String` from a `StringBuilder`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: StringBuilder = beginString();\n' + + '/// let buzz: String = fizz.toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertostring\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toString(self: StringBuilder): String;\n' + + '\n' + + '/// Extension function for the `StringBuilder` type.\n' + + '///\n' + + '/// Returns an assembled `Cell` as a `Slice` from a `StringBuilder`.\n' + + '/// An alias to `self.toCell().asSlice()`.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StringBuilder = beginString();\n' + + '/// let fizz: Slice = s.toSlice();\n' + + '/// let buzz: Slice = s.toCell().asSlice();\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#stringbuildertoslice\n' + + '///\n' + + '@name(__tact_string_builder_end_slice)\n' + + 'extends native toSlice(self: StringBuilder): Slice;\n' + + '\n' + + '//\n' + + '// String conversion\n' + + '//\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (84 - 42).toString();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttostring\n' + + '///\n' + + 'asm extends fun toString(self: Int): String {\n' + + ' // x\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representation] of a fractional\n' + + '/// number, where `self` is the significant part of the number and `digits` is the number\n' + + '/// of digits in the fractional part.\n' + + '///\n' + + '/// NOTE: **Gas expensive!** This function uses 500 gas units or more.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fizz: String = (42).toFloatString(9); // "0.000000042"\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 134: [Invalid argument] — Thrown when the given `digits` value is out of range.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-strings#inttofloatstring\n' + + '///\n' + + '/// [fixed-point representation]: https://en.wikipedia.org/wiki/Fixed-point_arithmetic\n' + + '/// [Invalid argument]: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'asm extends fun toFloatString(self: Int, digits: Int): String {\n' + + ' // x digits\n' + + '\n' + + ' DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s\n' + + '}\n' + + '\n' + + '/// Extension function for the `Int` type.\n' + + '///\n' + + '/// Returns a `String` from an `Int` value using a [fixed-point representatio'... 6219 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginString', + loc: { start: 329, end: 340 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 344, end: 357 } + }, + typeArgs: [], + loc: { start: 344, end: 357 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_string', + loc: { start: 286, end: 320 } + } + }, + loc: { start: 280, end: 358 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginComment', + loc: { start: 830, end: 842 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 846, end: 859 } + }, + typeArgs: [], + loc: { start: 846, end: 859 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_comment', + loc: { start: 786, end: 821 } + } + }, + loc: { start: 780, end: 860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginTailString', + loc: { start: 1341, end: 1356 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1360, end: 1373 } + }, + typeArgs: [], + loc: { start: 1360, end: 1373 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start_tail_string', + loc: { start: 1293, end: 1332 } + } + }, + loc: { start: 1287, end: 1374 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'beginStringFromBuilder', + loc: { start: 1836, end: 1858 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 1872, end: 1885 } + }, + typeArgs: [], + loc: { start: 1872, end: 1885 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'b', + loc: { start: 1859, end: 1860 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 1862, end: 1869 } + }, + loc: { start: 1862, end: 1869 } + }, + loc: { start: 1859, end: 1869 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_start', + loc: { start: 1800, end: 1827 } + } + }, + loc: { start: 1794, end: 1886 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'append', + loc: { start: 2328, end: 2334 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2356, end: 2357 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2359, end: 2365 } + }, + typeArgs: [], + loc: { start: 2359, end: 2365 } + }, + loc: { start: 2356, end: 2365 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append', + loc: { start: 2275, end: 2303 } + } + }, + loc: { start: 2269, end: 2367 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2341, end: 2354 } + }, + typeArgs: [], + loc: { start: 2341, end: 2354 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'concat', + loc: { start: 2880, end: 2886 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2920, end: 2933 } + }, + typeArgs: [], + loc: { start: 2920, end: 2933 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 2908, end: 2909 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 2911, end: 2917 } + }, + typeArgs: [], + loc: { start: 2911, end: 2917 } + }, + loc: { start: 2908, end: 2917 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_append_not_mut', + loc: { start: 2827, end: 2863 } + } + }, + loc: { start: 2821, end: 2934 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 2893, end: 2906 } + }, + typeArgs: [], + loc: { start: 2893, end: 2906 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toCell', + loc: { start: 3392, end: 3398 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3421, end: 3425 } + }, + loc: { start: 3421, end: 3425 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end', + loc: { start: 3350, end: 3375 } + } + }, + loc: { start: 3344, end: 3426 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3405, end: 3418 } + }, + typeArgs: [], + loc: { start: 3405, end: 3418 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 3893, end: 3901 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 3924, end: 3930 } + }, + typeArgs: [], + loc: { start: 3924, end: 3930 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 3845, end: 3876 } + } + }, + loc: { start: 3839, end: 3931 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 3908, end: 3921 } + }, + typeArgs: [], + loc: { start: 3908, end: 3921 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toSlice', + loc: { start: 4530, end: 4537 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 4560, end: 4565 } + }, + loc: { start: 4560, end: 4565 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_string_builder_end_slice', + loc: { start: 4482, end: 4513 } + } + }, + loc: { start: 4476, end: 4566 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 4544, end: 4557 } + }, + typeArgs: [], + loc: { start: 4544, end: 4557 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 4950, end: 4958 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 4971, end: 4977 } + }, + typeArgs: [], + loc: { start: 4971, end: 4977 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '<{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' OVER // x b x\n' + + ' 0 LESSINT // x b <0?\n' + + ' <{\n' + + ' // x b\n' + + ' 45 PUSHINT // x b 45\n' + + ' SWAP // x 45 b\n' + + ' 8 STU // x b\n' + + ' SWAP // b x\n' + + ' NEGATE // b -x\n' + + ' SWAP // -x b\n' + + ' }>CONT IF\n' + + ' // x b\n' + + '\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 1 1 CALLXARGS\n' + + ' // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 4934, end: 5692 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4965, end: 4968 } + }, + loc: { start: 4965, end: 4968 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toFloatString', + loc: { start: 6527, end: 6540 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 6566, end: 6572 } + }, + typeArgs: [], + loc: { start: 6566, end: 6572 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'digits', + loc: { start: 6552, end: 6558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6560, end: 6563 } + }, + loc: { start: 6552, end: 6563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'DUP // x digits digits\n' + + ' 1 LESSINT // x digits digits<=0\n' + + ' 134 THROWIF // x digits\n' + + ' DUP // x digits digits\n' + + ' 77 GTINT // x digits digits>77\n' + + ' 134 THROWIF // x digits\n' + + '\n' + + ' NEWC // x digits b\n' + + ' ROTREV // b x digits\n' + + ' s1 PUSH // b x digits x\n' + + ' 0 LESSINT // b x digits x<0?\n' + + '\n' + + ' <{\n' + + ' // b x digits\n' + + ' ROT // x digits b\n' + + ' x{2d} STSLICECONST // x digits b\n' + + ' ROT // digits b x\n' + + ' NEGATE // digits b -x\n' + + ' ROT // b -x digits\n' + + ' }>CONT IF\n' + + '\n' + + ' // b x digits\n' + + ' ONE // b x digits 1\n' + + ' OVER // b x digits 1 digits\n' + + '\n' + + ' <{ 10 MULCONST }>CONT REPEAT // b x digits 10^digits\n' + + '\n' + + ' s1 s2 XCHG // b digits x 10^digits\n' + + ' DIVMOD // b digits left right\n' + + ' s3 s3 XCHG2 // right digits b left\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC // ... b n\n' + + ' <{ 8 STU }>CONT REPEAT // b\n' + + ' }>CONT 2 1 CALLXARGS\n' + + '\n' + + ' // right digits "left"\n' + + '\n' + + ' ROT // digits "left" right\n' + + ' DUP // digits "left" right right\n' + + ' ISZERO // digits "left" right right==0?\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' DROP // digits "left"\n' + + ' NIP // "left"\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" right\n' + + ' ZERO // digits "left" right 0\n' + + ' SWAP // digits "left" 0 right\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' DUP // digits "left" i right right\n' + + ' 10 PUSHINT // digits "left" i right right 10\n' + + ' MOD // digits "left" i right right%10\n' + + ' ISZERO // digits "left" i right right%10==0?\n' + + ' }>CONT\n' + + '\n' + + ' <{\n' + + ' // digits "left" i right\n' + + ' 10 PUSHINT // digits "left" i right 10\n' + + ' DIV // digits "left" i right/10\n' + + ' SWAP // digits "left" right/10 i\n' + + ' INC // digits "left" right/10 i+1\n' + + ' SWAP // digits "left" i+1 right/10\n' + + ' }>CONT\n' + + '\n' + + ' WHILE // digits "left" i right\n' + + '\n' + + ' <{\n' + + ' // x\n' + + ' NEWC // x b\n' + + ' SWAP // b x\n' + + '\n' + + ' <{\n' + + ' // b x\n' + + ' 10 PUSHINT DIVMOD // b x/10 x%10\n' + + ' 48 ADDCONST // b x/10 (x%10+48)\n' + + ' s2 s2 s0 XC2PU ISZERO // (x%10+48) b x/10 x/10==0?\n' + + ' }>CONT UNTIL\n' + + ' // ... b x\n' + + '\n' + + ' DROP // ... b\n' + + ' DEPTH DEC DUP // ... b n n\n' + + ' ROTREV // ... n b n\n' + + ' <{\n' + + ' // ... c n b\n' + + ' s1 s2 XCHG // ... n c b\n' + + ' 8 STU // ... n b\n' + + ' }>CONT REPEAT // n b\n' + + ' }>CONT 1 2 CALLXARGS\n' + + ' // digits "left" i right_digits "right"\n' + + ' ROTREV // digits "left" "right" i right_digits\n' + + ' ADD // digits "left" "right" right_digits\n' + + '\n' + + ' s3 s1 XCHG // "right" "left" digits right_digits\n' + + ' SUB // "right" "left" digits_diff\n' + + ' SWAP // "right" digits_diff "left"\n' + + ' x{2e} STSLICECONST // "right" digits_diff "left."\n' + + ' SWAP // "right" "left." digits_diff\n' + + '\n' + + ' <{\n' + + ' // "right" "left."\n' + + ' x{30} STSLICECONST // "right" "left.0"\n' + + ' }>CONT REPEAT // "right" "left.000"\n' + + '\n' + + ' STB // "left.000right"\n' + + ' }>CONT\n' + + '\n' + + ' IFELSE // b\n' + + '\n' + + ' ENDC CTOS // s' + ] + }, + loc: { start: 6511, end: 9874 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6547, end: 6550 } + }, + loc: { start: 6547, end: 6550 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'toCoinsString', + loc: { start: 10653, end: 10666 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 10679, end: 10685 } + }, + typeArgs: [], + loc: { start: 10679, end: 10685 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 10699, end: 10703 } + }, + method: { + kind: 'id', + text: 'toFloatString', + loc: { start: 10704, end: 10717 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 9n, + loc: { start: 10718, end: 10719 } + } + ], + loc: { start: 10699, end: 10720 } + }, + loc: { start: 10692, end: 10721 } + } + ] + }, + loc: { start: 10634, end: 10723 } + } + }, + selfType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10673, end: 10676 } + }, + loc: { start: 10673, end: 10676 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asComment', + loc: { start: 11442, end: 11451 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 11467, end: 11471 } + }, + loc: { start: 11467, end: 11471 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'b', + loc: { start: 11482, end: 11483 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StringBuilder', + loc: { start: 11485, end: 11498 } + }, + typeArgs: [], + loc: { start: 11485, end: 11498 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginComment', + loc: { start: 11501, end: 11513 } + }, + typeArgs: [], + args: [], + loc: { start: 11501, end: 11515 } + }, + loc: { start: 11478, end: 11516 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11521, end: 11522 } + }, + method: { + kind: 'id', + text: 'append', + loc: { start: 11523, end: 11529 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 11530, end: 11534 } + } + ], + loc: { start: 11521, end: 11535 } + }, + loc: { start: 11521, end: 11536 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'b', + loc: { start: 11548, end: 11549 } + }, + method: { + kind: 'id', + text: 'toCell', + loc: { start: 11550, end: 11556 } + }, + typeArgs: [], + args: [], + loc: { start: 11548, end: 11558 } + }, + loc: { start: 11541, end: 11559 } + } + ] + }, + loc: { start: 11430, end: 11561 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 11458, end: 11464 } + }, + typeArgs: [], + loc: { start: 11458, end: 11464 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 12075, end: 12082 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 12098, end: 12103 } + }, + loc: { start: 12098, end: 12103 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_str_to_slice', + loc: { start: 12039, end: 12058 } + } + }, + loc: { start: 12033, end: 12104 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12089, end: 12095 } + }, + typeArgs: [], + loc: { start: 12089, end: 12095 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asString', + loc: { start: 12598, end: 12606 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 12621, end: 12627 } + }, + typeArgs: [], + loc: { start: 12621, end: 12627 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_slice_to_str', + loc: { start: 12562, end: 12581 } + } + }, + loc: { start: 12556, end: 12628 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 12613, end: 12618 } + }, + loc: { start: 12613, end: 12618 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13537, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 13563, end: 13568 } + }, + loc: { start: 13563, end: 13568 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 13582, end: 13586 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 13587, end: 13594 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13596 } + }, + method: { + kind: 'id', + text: 'fromBase64', + loc: { start: 13597, end: 13607 } + }, + typeArgs: [], + args: [], + loc: { start: 13582, end: 13609 } + }, + loc: { start: 13575, end: 13610 } + } + ] + }, + loc: { start: 13518, end: 13612 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 13554, end: 13560 } + }, + typeArgs: [], + loc: { start: 13554, end: 13560 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'fromBase64', + loc: { start: 14642, end: 14652 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 14667, end: 14672 } + }, + loc: { start: 14667, end: 14672 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'size', + loc: { start: 14683, end: 14687 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14689, end: 14692 } + }, + loc: { start: 14689, end: 14692 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14695, end: 14699 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 14700, end: 14704 } + }, + typeArgs: [], + args: [], + loc: { start: 14695, end: 14706 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14709, end: 14710 } + }, + loc: { start: 14695, end: 14710 } + }, + loc: { start: 14679, end: 14711 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 14720, end: 14726 } + }, + type: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 14728, end: 14735 } + }, + loc: { start: 14728, end: 14735 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 14738, end: 14747 } + }, + typeArgs: [], + args: [], + loc: { start: 14738, end: 14749 } + }, + loc: { start: 14716, end: 14750 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'size', + loc: { start: 14764, end: 14768 } + }, + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'code', + loc: { start: 14784, end: 14788 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14790, end: 14793 } + }, + loc: { start: 14790, end: 14793 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 14796, end: 14800 } + }, + method: { + kind: 'id', + text: 'loadUint', + loc: { start: 14801, end: 14809 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 14810, end: 14811 } + } + ], + loc: { start: 14796, end: 14812 } + }, + loc: { start: 14780, end: 14813 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14826, end: 14830 } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { start: 14834, end: 14836 } + }, + loc: { start: 14826, end: 14836 } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { start: 14840, end: 14844 } + }, + right: { + kind: 'number', + base: '10', + value: 90n, + loc: { start: 14848, end: 14850 } + }, + loc: { start: 14840, end: 14850 } + }, + loc: { start: 14826, end: 14850 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { start: 14873, end: 14879 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 14882, + end: 14888 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 14889, + end: 14898 + } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { + start: 14899, + end: 14903 + } + }, + right: { + kind: 'number', + base: '10', + value: 65n, + loc: { + start: 14906, + end: 14908 + } + }, + loc: { + start: 14899, + end: 14908 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 14910, + end: 14911 + } + } + ], + loc: { start: 14882, end: 14912 } + }, + loc: { start: 14873, end: 14913 } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { + start: 14933, + end: 14937 + } + }, + right: { + kind: 'number', + base: '10', + value: 97n, + loc: { + start: 14941, + end: 14943 + } + }, + loc: { + start: 14933, + end: 14943 + } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { + start: 14947, + end: 14951 + } + }, + right: { + kind: 'number', + base: '10', + value: 122n, + loc: { + start: 14955, + end: 14958 + } + }, + loc: { + start: 14947, + end: 14958 + } + }, + loc: { start: 14933, end: 14958 } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 14981, + end: 14987 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 14990, + end: 14996 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 14997, + end: 15006 + } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15007, + end: 15011 + } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 97n, + loc: { + start: 15015, + end: 15017 + } + }, + right: { + kind: 'number', + base: '10', + value: 26n, + loc: { + start: 15020, + end: 15022 + } + }, + loc: { + start: 15015, + end: 15022 + } + }, + loc: { + start: 15007, + end: 15023 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15025, + end: 15026 + } + } + ], + loc: { + start: 14990, + end: 15027 + } + }, + loc: { + start: 14981, + end: 15028 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '&&', + left: { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15048, + end: 15052 + } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { + start: 15056, + end: 15058 + } + }, + loc: { + start: 15048, + end: 15058 + } + }, + right: { + kind: 'op_binary', + op: '<=', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15062, + end: 15066 + } + }, + right: { + kind: 'number', + base: '10', + value: 57n, + loc: { + start: 15070, + end: 15072 + } + }, + loc: { + start: 15062, + end: 15072 + } + }, + loc: { + start: 15048, + end: 15072 + } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 15095, + end: 15101 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15104, + end: 15110 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15111, + end: 15120 + } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15121, + end: 15125 + } + }, + right: { + kind: 'op_binary', + op: '-', + left: { + kind: 'number', + base: '10', + value: 52n, + loc: { + start: 15129, + end: 15131 + } + }, + right: { + kind: 'number', + base: '10', + value: 48n, + loc: { + start: 15134, + end: 15136 + } + }, + loc: { + start: 15129, + end: 15136 + } + }, + loc: { + start: 15121, + end: 15137 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15139, + end: 15140 + } + } + ], + loc: { + start: 15104, + end: 15141 + } + }, + loc: { + start: 15095, + end: 15142 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15162, + end: 15166 + } + }, + right: { + kind: 'number', + base: '10', + value: 45n, + loc: { + start: 15170, + end: 15172 + } + }, + loc: { + start: 15162, + end: 15172 + } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15176, + end: 15180 + } + }, + right: { + kind: 'number', + base: '10', + value: 43n, + loc: { + start: 15184, + end: 15186 + } + }, + loc: { + start: 15176, + end: 15186 + } + }, + loc: { + start: 15162, + end: 15186 + } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 15212, + end: 15218 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15221, + end: 15227 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15228, + end: 15237 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 62n, + loc: { + start: 15238, + end: 15240 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15242, + end: 15243 + } + } + ], + loc: { + start: 15221, + end: 15244 + } + }, + loc: { + start: 15212, + end: 15245 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '||', + left: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15265, + end: 15269 + } + }, + right: { + kind: 'number', + base: '10', + value: 95n, + loc: { + start: 15273, + end: 15275 + } + }, + loc: { + start: 15265, + end: 15275 + } + }, + right: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15279, + end: 15283 + } + }, + right: { + kind: 'number', + base: '10', + value: 47n, + loc: { + start: 15287, + end: 15289 + } + }, + loc: { + start: 15279, + end: 15289 + } + }, + loc: { + start: 15265, + end: 15289 + } + }, + trueStatements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'result', + loc: { + start: 15315, + end: 15321 + } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { + start: 15324, + end: 15330 + } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { + start: 15331, + end: 15340 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 63n, + loc: { + start: 15341, + end: 15343 + } + }, + { + kind: 'number', + base: '10', + value: 6n, + loc: { + start: 15345, + end: 15346 + } + } + ], + loc: { + start: 15324, + end: 15347 + } + }, + loc: { + start: 15315, + end: 15348 + } + } + ], + falseStatements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'code', + loc: { + start: 15368, + end: 15372 + } + }, + right: { + kind: 'number', + base: '10', + value: 61n, + loc: { + start: 15376, + end: 15378 + } + }, + loc: { + start: 15368, + end: 15378 + } + }, + trueStatements: [], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throw', + loc: { + start: 15436, + end: 15441 + } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidArgument', + loc: { + start: 15442, + end: 15469 + } + } + ], + loc: { + start: 15436, + end: 15470 + } + }, + loc: { + start: 15436, + end: 15471 + } + } + ], + loc: { + start: 15364, + end: 15481 + } + } + ], + loc: { + start: 15261, + end: 15481 + } + } + ], + loc: { + start: 15158, + end: 15481 + } + } + ], + loc: { + start: 15044, + end: 15481 + } + } + ], + loc: { start: 14929, end: 15481 } + } + ], + loc: { start: 14822, end: 15481 } + } + ], + loc: { start: 14756, end: 15487 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'total', + loc: { start: 15512, end: 15517 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15519, end: 15522 } + }, + loc: { start: 15519, end: 15522 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15525, end: 15531 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 15532, end: 15536 } + }, + typeArgs: [], + args: [], + loc: { start: 15525, end: 15538 } + }, + loc: { start: 15508, end: 15539 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'padding', + loc: { start: 15548, end: 15555 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15557, end: 15560 } + }, + loc: { start: 15557, end: 15560 } + }, + expression: { + kind: 'op_binary', + op: '%', + left: { + kind: 'var', + name: 'total', + loc: { start: 15563, end: 15568 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 15571, end: 15572 } + }, + loc: { start: 15563, end: 15572 } + }, + loc: { start: 15544, end: 15573 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '!=', + left: { + kind: 'var', + name: 'padding', + loc: { start: 15582, end: 15589 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15593, end: 15594 } + }, + loc: { start: 15582, end: 15594 } + }, + trueStatements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15610, end: 15611 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 15613, end: 15618 } + }, + loc: { start: 15613, end: 15618 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15621, end: 15627 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15628, end: 15635 } + }, + typeArgs: [], + args: [], + loc: { start: 15621, end: 15637 } + }, + loc: { start: 15606, end: 15638 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 's', + loc: { start: 15654, end: 15655 } + }, + method: { + kind: 'id', + text: 'loadBits', + loc: { start: 15656, end: 15664 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'total', + loc: { + start: 15665, + end: 15670 + } + }, + right: { + kind: 'var', + name: 'padding', + loc: { + start: 15673, + end: 15680 + } + }, + loc: { start: 15665, end: 15680 } + } + ], + loc: { start: 15654, end: 15681 } + }, + loc: { start: 15647, end: 15682 } + } + ], + falseStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'result', + loc: { start: 15711, end: 15717 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 15718, end: 15725 } + }, + typeArgs: [], + args: [], + loc: { start: 15711, end: 15727 } + }, + loc: { start: 15704, end: 15728 } + } + ], + loc: { start: 15578, end: 15734 } + } + ] + }, + loc: { start: 14630, end: 15736 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 14659, end: 14664 } + }, + loc: { start: 14659, end: 14664 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'toString', + loc: { start: 16186, end: 16194 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'String', + loc: { start: 16211, end: 16217 } + }, + typeArgs: [], + loc: { start: 16211, end: 16217 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_address_to_user_friendly', + loc: { start: 16138, end: 16169 } + } + }, + loc: { start: 16132, end: 16218 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 16201, end: 16208 } + }, + typeArgs: [], + loc: { start: 16201, end: 16208 } + } + } + ] + }, + loc: { start: 119, end: 144 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/math.tact', + code: '// Prepare random\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the pseudorandom number generator with the specified unsigned 256-bit `Int` `x` by mixing it with the current seed. The new seed is the unsigned 256-bit `Int` value of the SHA-256 hash of concatenated old seed and `x` in their 32-byte strings big-endian representation.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomize(42); // now, random numbers are less predictable\n' + + "/// let idk: Int = randomInt(); // ???, it's random,\n" + + '/// // but the seed was adjusted deterministically!\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `x`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun nativeRandomize(x: Int) { ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Randomizes the random number generator with the logical time of the current transaction. Equivalent to calling `nativeRandomize(curLt())`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativeRandomizeLt(); // now, random numbers are unpredictable for users,\n' + + '/// // but still may be affected by validators or collators\n' + + '/// // as they determine the seed of the current block.\n' + + "/// let idk: Int = randomInt(); // ???, it's random!\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'asm fun nativeRandomizeLt() { LTIME ADDRAND }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Prepares a random number generator by using `nativeRandomizeLt()`. Automatically called by `randomInt()` and `random()` functions.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// nativePrepareRandom(); // prepare the RNG\n' + + '/// // ... do your random things ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativepreparerandom\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#randomint\n' + + '/// * https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + '@name(__tact_prepare_random)\n' + + 'native nativePrepareRandom();\n' + + '\n' + + '// Random\n' + + '\n' + + '// Generates a new pseudo-random unsigned 256-bit integer x.\n' + + '// The algorithm is as follows: if r is the old value of the random seed,\n' + + '// considered as a 32-byte array (by constructing the big-endian representation\n' + + '// of an unsigned 256-bit integer), then its sha512(r) is computed;\n' + + "// the first 32 bytes of this hash are stored as the new value r' of the random seed,\n" + + '// and the remaining 32 bytes are returned as the next random value x.\n' + + 'asm fun nativeRandom(): Int { RANDU256 }\n' + + '\n' + + '// Generates a new pseudo-random integer z in the range 0..range−1\n' + + '// (or range..−1, if range < 0).\n' + + '// More precisely, an unsigned random value x is generated as in `nativeRandom`;\n' + + '// then z := x * range / 2^256 is computed.\n' + + 'asm fun nativeRandomInterval(max: Int): Int { RAND }\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned 256-bit `Int` value `x`.\n' + + '///\n' + + '/// The algorithm works as follows: first, the `sha512(r)` is computed. There, `r` is an old\n' + + '/// value of the random seed, which is taken as a 32-byte array constructed from the big-endian\n' + + '/// representation of an unsigned 256-bit `Int`. The first 32 bytes of this hash are stored as the new\n' + + "/// value `r'` of the random seed, and the remaining 32 bytes are returned as the next random value `x`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let allYourRandomBelongToUs: Int = randomInt(); // ???, it's random :)\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#randomint\n' + + '///\n' + + 'inline fun randomInt(): Int {\n' + + ' nativePrepareRandom();\n' + + ' return nativeRandom();\n' + + '}\n' + + '\n' + + '/// Generates and returns a new pseudo-random unsigned `Int` value `x` in the provided semi-closed\n' + + '/// interval: `min` ≤ `x` < `max`, or `min` ≥ `x` > `max` if both `min` and `max` are negative.\n' + + '///\n' + + '/// Note that the `max` value is never included in the interval.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// random(42, 43); // 42, always\n' + + '/// random(0, 42); // 0-41, but never 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-random#random\n' + + '///\n' + + 'inline fun random(min: Int, max: Int): Int {\n' + + ' nativePrepareRandom();\n' + + ' return min + nativeRandomInterval(max - min);\n' + + '}\n' + + '\n' + + '// Math\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the minimum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// min(1, 2); // 1\n' + + '/// min(2, 2); // 2\n' + + '/// min(007, 3); // 3\n' + + '/// min(0x45, 3_0_0); // 69, nice\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#min\n' + + '///\n' + + 'asm fun min(x: Int, y: Int): Int { MIN }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the maximum of two `Int` values `x` and `y`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// max(1, 2); // 2\n' + + '/// max(2, 2); // 2\n' + + '/// max(007, 3); // 7\n' + + '/// max(0x45, 3_0_0); // 300\n' + + '/// // ↑ ↑\n' + + '/// // 69 300\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#max\n' + + '///\n' + + 'asm fun max(x: Int, y: Int): Int { MAX }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the absolute value of the `Int` value `x`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// abs(42); // 42\n' + + '/// abs(-42); // 42\n' + + '/// abs(-(-(-42))); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-math#abs\n' + + '///\n' + + 'asm fun abs(x: Int): Int { ABS }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the logarithm of a number `num` > 0 to the base `base` ≥ 1. Results are rounded down.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// log(1000, 10); // 3, as 10^3 is 1000\n' + + '/// // ↑ ↑ ↑ ↑\n' + + '/// // num base base num\n' + + '///\n' + + '/// log(1001, 10); // 3\n' + + '/// log(999, 10); // 2\n' + + '/// try {\n' + + '/// log(-1000, 10); // exit code 5 because of the non-positive num\n' + + '/// }\n' + + '/// log(1024, 2); // 10\n' + + '/// try {\n' + + '/// log(1024, -2); // exit code 5 because the base is less than 1\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive\n' + + '/// or the given `base` value is less than 1.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '///\n' + + '@name(__tact_log)\n' + + 'native log(num: Int, base: Int): Int;\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `log()`, but sets the `base` to 2.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// log2(1024); // 10, as 2^10 is 1024\n' + + '/// // ↑ ↑ ↑\n' + + '/// // num base₂ num\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `num` value is non-positive.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#log.\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'asm fun log2(num: Int): Int { DUP 5 THROWIFNOT UBITSIZE DEC }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Computes and returns the exponentiation involving two numbers: the `base` and the exponent (or _power_) `exp`.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow(2, 3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow(5, 0); // raises 5 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver\n' + + '/// receive() {\n' + + '/// pow(self.p23, self.one + 1); // 64, works at run-time too!\n' + + '/// try {\n' + + '/// pow(0, -1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when the given `exp` value is negative.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes/#5\n' + + '///\n' + + 'inline fun pow(base: Int, exp: Int): Int {\n' + + ' throwUnless(5, exp >= 0);\n' + + ' let result = 1;\n' + + ' repeat (exp) {\n' + + ' result *= base;\n' + + ' }\n' + + ' return result;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Similar to `pow()`, but sets the `base` to 2.\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Example {\n' + + '/// // Persistent state variables\n' + + '/// p23: Int = pow2(3); // raises 2 to the 3rd power, which is 8\n' + + '/// one: Int = pow2(0); // raises 2 to the power 0, which always produces 1\n' + + '/// // works at compile-time!\n' + + '///\n' + + '/// // Internal message receiver, which accepts message ExtMsg\n' + + '/// receive() {\n' + + '/// pow2(self.one + 1); // 4, works at run-time too!\n' + + '/// try {\n' + + '/// pow(-1); // exit code 5: Integer out of expected range\n' + + '/// }\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify a negative value of `exp`.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow2\n' + + '/// * https://docs.tact-lang.org/ref/core-math#pow\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun pow2(exp: Int): Int { POW2 }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns the sign of the `Int` value `x`. Produces 1 if the `x` is positive, -1 if the `x` is negative, and 0 if the `x` is 0.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun examples() {\n' + + '/// '... 5983 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomize', + loc: { start: 965, end: 980 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 981, end: 982 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 984, end: 987 } + }, + loc: { start: 984, end: 987 } + }, + loc: { start: 981, end: 987 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ADDRAND' ] + }, + loc: { start: 957, end: 1000 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomizeLt', + loc: { start: 1822, end: 1839 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME ADDRAND' ] + }, + loc: { start: 1814, end: 1859 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 2466, end: 2485 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_prepare_random', + loc: { start: 2436, end: 2457 } + } + }, + loc: { start: 2430, end: 2488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 2949, end: 2961 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2965, end: 2968 } + }, + loc: { start: 2965, end: 2968 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDU256' ] + }, + loc: { start: 2941, end: 2981 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 3216, end: 3236 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3248, end: 3251 } + }, + loc: { start: 3248, end: 3251 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 3237, end: 3240 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3242, end: 3245 } + }, + loc: { start: 3237, end: 3245 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAND' ] + }, + loc: { start: 3208, end: 3260 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'randomInt', + loc: { start: 3953, end: 3962 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3966, end: 3969 } + }, + loc: { start: 3966, end: 3969 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 3976, end: 3995 } + }, + typeArgs: [], + args: [], + loc: { start: 3976, end: 3997 } + }, + loc: { start: 3976, end: 3998 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandom', + loc: { start: 4010, end: 4022 } + }, + typeArgs: [], + args: [], + loc: { start: 4010, end: 4024 } + }, + loc: { start: 4003, end: 4025 } + } + ] + }, + loc: { start: 3942, end: 4027 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'random', + loc: { start: 4505, end: 4511 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4533, end: 4536 } + }, + loc: { start: 4533, end: 4536 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'min', + loc: { start: 4512, end: 4515 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4517, end: 4520 } + }, + loc: { start: 4512, end: 4520 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'max', + loc: { start: 4522, end: 4525 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4527, end: 4530 } + }, + loc: { start: 4522, end: 4530 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativePrepareRandom', + loc: { start: 4543, end: 4562 } + }, + typeArgs: [], + args: [], + loc: { start: 4543, end: 4564 } + }, + loc: { start: 4543, end: 4565 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 'min', + loc: { start: 4577, end: 4580 } + }, + right: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeRandomInterval', + loc: { start: 4583, end: 4603 } + }, + typeArgs: [], + args: [ + { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'max', + loc: { start: 4604, end: 4607 } + }, + right: { + kind: 'var', + name: 'min', + loc: { start: 4610, end: 4613 } + }, + loc: { start: 4604, end: 4613 } + } + ], + loc: { start: 4583, end: 4614 } + }, + loc: { start: 4577, end: 4614 } + }, + loc: { start: 4570, end: 4615 } + } + ] + }, + loc: { start: 4494, end: 4617 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'min', + loc: { start: 5017, end: 5020 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5038, end: 5041 } + }, + loc: { start: 5038, end: 5041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5021, end: 5022 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5024, end: 5027 } + }, + loc: { start: 5021, end: 5027 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5029, end: 5030 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5032, end: 5035 } + }, + loc: { start: 5029, end: 5035 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MIN' ] + }, + loc: { start: 5009, end: 5049 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'max', + loc: { start: 5435, end: 5438 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5456, end: 5459 } + }, + loc: { start: 5456, end: 5459 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5439, end: 5440 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5442, end: 5445 } + }, + loc: { start: 5439, end: 5445 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 5447, end: 5448 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5450, end: 5453 } + }, + loc: { start: 5447, end: 5453 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MAX' ] + }, + loc: { start: 5427, end: 5467 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'abs', + loc: { start: 5773, end: 5776 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5786, end: 5789 } + }, + loc: { start: 5786, end: 5789 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 5777, end: 5778 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5780, end: 5783 } + }, + loc: { start: 5777, end: 5783 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ABS' ] + }, + loc: { start: 5765, end: 5797 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'log', + loc: { start: 6721, end: 6724 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6747, end: 6750 } + }, + loc: { start: 6747, end: 6750 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 6725, end: 6728 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6730, end: 6733 } + }, + loc: { start: 6725, end: 6733 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 6735, end: 6739 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6741, end: 6744 } + }, + loc: { start: 6735, end: 6744 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_log', + loc: { start: 6702, end: 6712 } + } + }, + loc: { start: 6696, end: 6751 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'log2', + loc: { start: 7341, end: 7345 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7357, end: 7360 } + }, + loc: { start: 7357, end: 7360 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 7346, end: 7349 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7351, end: 7354 } + }, + loc: { start: 7346, end: 7354 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUP 5 THROWIFNOT UBITSIZE DEC' ] + }, + loc: { start: 7333, end: 7394 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'pow', + loc: { start: 8510, end: 8513 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8536, end: 8539 } + }, + loc: { start: 8536, end: 8539 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'base', + loc: { start: 8514, end: 8518 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8520, end: 8523 } + }, + loc: { start: 8514, end: 8523 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 8525, end: 8528 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8530, end: 8533 } + }, + loc: { start: 8525, end: 8533 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 8546, end: 8557 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 5n, + loc: { start: 8558, end: 8559 } + }, + { + kind: 'op_binary', + op: '>=', + left: { + kind: 'var', + name: 'exp', + loc: { start: 8561, end: 8564 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 8568, end: 8569 } + }, + loc: { start: 8561, end: 8569 } + } + ], + loc: { start: 8546, end: 8570 } + }, + loc: { start: 8546, end: 8571 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'result', + loc: { start: 8580, end: 8586 } + }, + type: undefined, + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 8589, end: 8590 } + }, + loc: { start: 8576, end: 8591 } + }, + { + kind: 'statement_repeat', + iterations: { + kind: 'var', + name: 'exp', + loc: { start: 8604, end: 8607 } + }, + statements: [ + { + kind: 'statement_augmentedassign', + op: '*=', + path: { + kind: 'var', + name: 'result', + loc: { start: 8619, end: 8625 } + }, + expression: { + kind: 'var', + name: 'base', + loc: { start: 8629, end: 8633 } + }, + loc: { start: 8619, end: 8634 } + } + ], + loc: { start: 8596, end: 8640 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'result', + loc: { start: 8652, end: 8658 } + }, + loc: { start: 8645, end: 8659 } + } + ] + }, + loc: { start: 8499, end: 8661 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'pow2', + loc: { start: 9733, end: 9737 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9749, end: 9752 } + }, + loc: { start: 9749, end: 9752 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'exp', + loc: { start: 9738, end: 9741 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9743, end: 9746 } + }, + loc: { start: 9738, end: 9746 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'POW2' ] + }, + loc: { start: 9725, end: 9761 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sign', + loc: { start: 10233, end: 10237 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10247, end: 10250 } + }, + loc: { start: 10247, end: 10250 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10238, end: 10239 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10241, end: 10244 } + }, + loc: { start: 10238, end: 10244 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SGN' ] + }, + loc: { start: 10225, end: 10258 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'divc', + loc: { start: 10814, end: 10818 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10836, end: 10839 } + }, + loc: { start: 10836, end: 10839 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 10819, end: 10820 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10822, end: 10825 } + }, + loc: { start: 10819, end: 10825 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 10827, end: 10828 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10830, end: 10833 } + }, + loc: { start: 10827, end: 10833 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DIVC' ] + }, + loc: { start: 10806, end: 10848 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'muldivc', + loc: { start: 11615, end: 11622 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11648, end: 11651 } + }, + loc: { start: 11648, end: 11651 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 11623, end: 11624 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11626, end: 11629 } + }, + loc: { start: 11623, end: 11629 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 11631, end: 11632 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11634, end: 11637 } + }, + loc: { start: 11631, end: 11637 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 11639, end: 11640 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11642, end: 11645 } + }, + loc: { start: 11639, end: 11645 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULDIVC' ] + }, + loc: { start: 11607, end: 11663 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRight', + loc: { start: 12751, end: 12764 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12790, end: 12793 } + }, + loc: { start: 12790, end: 12793 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 12765, end: 12766 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12768, end: 12771 } + }, + loc: { start: 12765, end: 12771 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 12773, end: 12774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12776, end: 12779 } + }, + loc: { start: 12773, end: 12779 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 12781, end: 12782 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12784, end: 12787 } + }, + loc: { start: 12781, end: 12787 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFT' ] + }, + loc: { start: 12743, end: 12807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightRound', + loc: { start: 13862, end: 13880 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13906, end: 13909 } + }, + loc: { start: 13906, end: 13909 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 13881, end: 13882 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13884, end: 13887 } + }, + loc: { start: 13881, end: 13887 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 13889, end: 13890 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13892, end: 13895 } + }, + loc: { start: 13889, end: 13895 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 13897, end: 13898 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13900, end: 13903 } + }, + loc: { start: 13897, end: 13903 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTR' ] + }, + loc: { start: 13854, end: 13924 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'mulShiftRightCeil', + loc: { start: 14875, end: 14892 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14918, end: 14921 } + }, + loc: { start: 14918, end: 14921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'x', + loc: { start: 14893, end: 14894 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14896, end: 14899 } + }, + loc: { start: 14893, end: 14899 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'y', + loc: { start: 14901, end: 14902 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14904, end: 14907 } + }, + loc: { start: 14901, end: 14907 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'z', + loc: { start: 14909, end: 14910 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14912, end: 14915 } + }, + loc: { start: 14909, end: 14915 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MULRSHIFTC' ] + }, + loc: { start: 14867, end: 14936 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sqrt', + loc: { start: 15698, end: 15702 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15714, end: 15717 } + }, + loc: { start: 15714, end: 15717 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'num', + loc: { start: 15703, end: 15706 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15708, end: 15711 } + }, + loc: { start: 15703, end: 15711 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'num', + loc: { start: 15728, end: 15731 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15735, end: 15736 } + }, + loc: { start: 15728, end: 15736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15755, end: 15756 } + }, + loc: { start: 15748, end: 15757 } + } + ], + falseStatements: undefined, + loc: { start: 15724, end: 15763 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 's', + loc: { start: 15773, end: 15774 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15776, end: 15779 } + }, + loc: { start: 15776, end: 15779 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'log2', + loc: { start: 15782, end: 15786 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15787, end: 15790 } + } + ], + loc: { start: 15782, end: 15791 } + }, + loc: { start: 15769, end: 15792 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'x', + loc: { start: 15801, end: 15802 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15804, end: 15807 } + }, + loc: { start: 15804, end: 15807 } + }, + expression: { + kind: 'conditional', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 's', + loc: { start: 15811, end: 15812 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15816, end: 15817 } + }, + loc: { start: 15811, end: 15817 } + }, + thenBranch: { + kind: 'op_binary', + op: '+', + left: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'num', + loc: { start: 15821, end: 15824 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15827, end: 15828 } + }, + loc: { start: 15821, end: 15828 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15832, end: 15833 } + }, + loc: { start: 15820, end: 15833 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15836, end: 15837 } + }, + loc: { start: 15820, end: 15837 } + }, + elseBranch: { + kind: 'op_binary', + op: '<<', + left: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15840, end: 15841 } + }, + right: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '+', + left: { + kind: 'var', + name: 's', + loc: { start: 15847, end: 15848 } + }, + right: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 15851, end: 15852 } + }, + loc: { start: 15847, end: 15852 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15856, end: 15857 } + }, + loc: { start: 15846, end: 15857 } + }, + loc: { start: 15840, end: 15858 } + }, + loc: { start: 15811, end: 15858 } + }, + loc: { start: 15797, end: 15860 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'q', + loc: { start: 15870, end: 15871 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15873, end: 15876 } + }, + loc: { start: 15873, end: 15876 } + }, + expression: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15879, end: 15880 } + }, + loc: { start: 15866, end: 15881 } + }, + { + kind: 'statement_until', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'q', + loc: { start: 15957, end: 15958 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 15962, end: 15963 } + }, + loc: { start: 15957, end: 15963 } + }, + statements: [ + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'q', + loc: { start: 15900, end: 15901 } + }, + expression: { + kind: 'op_binary', + op: '/', + left: { + kind: 'op_binary', + op: '-', + left: { + kind: 'static_call', + function: { + kind: 'id', + text: 'divc', + loc: { start: 15905, end: 15909 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'num', + loc: { start: 15910, end: 15913 } + }, + { + kind: 'var', + name: 'x', + loc: { start: 15915, end: 15916 } + } + ], + loc: { start: 15905, end: 15917 } + }, + right: { + kind: 'var', + name: 'x', + loc: { start: 15920, end: 15921 } + }, + loc: { start: 15905, end: 15921 } + }, + right: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 15925, end: 15926 } + }, + loc: { start: 15904, end: 15926 } + }, + loc: { start: 15900, end: 15927 } + }, + { + kind: 'statement_augmentedassign', + op: '+=', + path: { + kind: 'var', + name: 'x', + loc: { start: 15936, end: 15937 } + }, + expression: { + kind: 'var', + name: 'q', + loc: { start: 15941, end: 15942 } + }, + loc: { start: 15936, end: 15943 } + } + ], + loc: { start: 15887, end: 15965 } + }, + { + kind: 'statement_return', + expression: { + kind: 'var', + name: 'x', + loc: { start: 15978, end: 15979 } + }, + loc: { start: 15971, end: 15980 } + } + ] + }, + loc: { start: 15694, end: 15982 } + } + ] + }, + loc: { start: 145, end: 170 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/contract.tact', + code: '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used.\n' + + '///\n' + + '/// This hash is commonly called account ID. Together with the workchain ID it deterministically forms the address of the contract on TON Blockchain.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let accountId: Int = contractHash(initPkg.code, initPkg.data);\n' + + '/// let basechainAddr: Address = newAddress(0, accountId);\n' + + '/// let basechainAddr2: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '///\n' + + '/// basechainAddr == basechainAddr2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contracthash\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '///\n' + + 'asm fun contractHash(code: Cell, data: Cell): Int {\n' + + ' // According to the https://docs.tact-lang.org/book/cells#cells-representation,\n' + + ' // the layout for the Builder to hash goes as follows:\n' + + ' // 1) refs_descriptor:bits8 | bits_descriptor:bits8 | data:bitsN\n' + + ' //\n' + + ' // refs_descriptor: ref_count + ((exotic? & 1) * 8) + (mask * 32)\n' + + ' // 2 refs (code + data), non-exotic, zero-mask\n' + + ' //\n' + + ' // bits_descriptor: floor(bit_count / 8) + ceil(bit_count, 8)\n' + + ' // floor (5 bits / 8) + ceil(5 bits / 8) = 0 + 1 = 1\n' + + ' //\n' + + ' // data: [0b00110] + [0b100] = [0b00110100] = 0x34 (data + augmented bits)\n' + + ' // 0b00110 - data (split_depth, special, code, data, Library)\n' + + ' // 0b100 - augmented bits (Leading 1 + zeroes to make section multiple of eight)\n' + + ' //\n' + + ' // That is: (2 << 16) | (1 << 8) | 0x34 = 131380 for all three.\n' + + ' //\n' + + ' // 2) and 3) depth_descriptors: CDEPTH of `code` and CDEPTH of `data`\n' + + ' // 4) and 5) ref hashes: HASHCU of `code` and HASHCU of `data`\n' + + '\n' + + ' // Group 1: Computations and arrangements\n' + + ' s0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the `chain` ID using the contract's `code` and the contract's initial state `data`. Use the `initOf` expression to obtain the initial `code` and initial `data` of a given contract.\n" + + '///\n' + + '/// This function lets you specify arbitrary `chain` IDs, including the common -1 (masterchain) and 0 (basechain) ones.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let initPkg: StateInit = initOf SomeContract();\n' + + '/// let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address {\n' + + ' let hash = contractHash(code, data);\n' + + ' return newAddress(chain, hash);\n' + + '}\n' + + '\n' + + '/// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'struct StateInit {\n' + + ' /// Initial code of the contract (compiled bitcode)\n' + + ' code: Cell;\n' + + '\n' + + ' /// Initial data of the contract (parameters of `init()` function or contract parameters)\n' + + ' data: Cell;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.1.\n' + + '///\n' + + '/// Efficiently compares if the given address matches the basechain address of the contract.\n' + + '/// Returns true if addresses are the same, false otherwise.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + "/// init.hasSameBasechainAddress(sender()); // returns true if sender matches contract's basechain address\n" + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// This function provides a gas-optimized implementation compared to direct address comparison:\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let init = initOf SomeContract();\n' + + '/// sender() == contractAddress(sender()); // less efficient approach\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note that this function works only for basechain addresses!\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '///\n' + + 'inline extends fun hasSameBasechainAddress(self: StateInit, sender: Address): Bool {\n' + + ' let senderAddress = parseStdAddress(sender.asSlice()).address;\n' + + ' let baseAddress = contractBasechainAddress(self);\n' + + ' return baseAddress.hash!! == senderAddress;\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + "/// Computes smart contract's `Address` in the workchain ID 0 (basechain) using the `StateInit` `s` of the contract. Alias to `contractAddressExt(0, s.code, s.data)`.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: StateInit = initOf SomeContract();\n' + + '/// let foundMeSome: Address = contractAddress(s);\n' + + '/// let andSomeMore: Address = contractAddressExt(0, s.code, s.data);\n' + + '///\n' + + '/// foundMeSome == andSomeMore; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#contractaddressext\n' + + '/// * https://docs.tact-lang.org/book/expressions#initof\n' + + '///\n' + + 'inline fun contractAddress(s: StateInit): Address {\n' + + ' return contractAddressExt(0, s.code, s.data);\n' + + '}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the address of the current smart contract as an `Address`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let meMyselfAndI: Address = myAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#myaddress\n' + + '///\n' + + 'asm fun myAddress(): Address { MYADDR }\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` balance of the smart contract as it was at the start of the compute phase of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let iNeedADolla: Int = myBalance();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mybalance\n' + + '///\n' + + 'asm fun myBalance(): Int { BALANCE FIRST }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of gas consumed by TVM in the current transaction so far. The resulting value includes the cost of calling this function.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let gas: Int = gasConsumed();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#gasconsumed\n' + + '///\n' + + 'asm fun gasConsumed(): Int { GASCONSUMED }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Returns the nanoToncoin `Int` amount of the accumulated storage fee debt. Storage fees are deducted from the incoming message value before the new contract balance is calculated.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let debt: Int = myStorageDue();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#mystoragedue\n' + + '///\n' + + 'asm fun myStorageDue(): Int { DUEPAYMENT }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the storage fee in nanoToncoins `Int` for storing a contract with a given number of `cells` and `bits` for a number of `seconds`. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 18 of TON Blockchain.\n' + + '///\n' + + '/// Note, that specifying values of `cells` and `bits` higher than their maximum values listed in account state limits (`max_acc_state_cells` and `max_acc_state_bits`) will have the same result as with specifying the exact limits. In addition, make sure you take into account the deduplication of cells with the same hash.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getStorageFee(1_000, 1_000, 1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative number of `cells`, `bits` or `seconds`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getstoragefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getStorageFee(cells: Int, bits: Int, seconds: Int, isMasterchain: Bool): Int { GETSTORAGEFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Calculates and returns the compute fee in nanoToncoins `Int` for a transaction that consumed `gasUsed` amount of gas. Uses the prices of the masterchain if `isMasterchain` is `true`, otherwise the prices of the basechain. The current prices are obtained from the config param 20 for the masterchain and config param 21 for the basechain of TON Blockchain.\n' + + '///\n' + + "/// When the `gasUsed` is less than a certain threshold called `flat_gas_limit`, there's a minimum price to pay based on the value of `flat_gas_price`. The less gas is used below this threshold, the higher the minimum price will be. See the example for `getSimpleComputeFee()` to derive that threshold.\n" + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fee: Int = getComputeFee(1_000, false);\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify negative value of `gasUsed`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-gas#getcomputefee\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + 'asm fun getComputeFee(gasUsed: Int, isMasterchain: Bool): Int { GETGASFEE }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Similar to `getComputeFee()`, but without the `flat_gas_price`, i.e. without a minimum price to pay if the `gasUsed` is less than a certain '... 8611 more characters, + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'contractHash', + loc: { start: 1027, end: 1039 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1065, end: 1068 } + }, + loc: { start: 1065, end: 1068 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1040, end: 1044 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1046, end: 1050 } + }, + loc: { start: 1040, end: 1050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 1052, end: 1056 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1058, end: 1062 } + }, + loc: { start: 1052, end: 1062 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 's0 PUSH HASHCU // `data` hash\n' + + ' s2 PUSH HASHCU // `code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `code` depth\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + '\n' + + ' // Group 2: Composition of the Builder\n' + + ' NEWC\n' + + ' 24 STU // store refs_descriptor | bits_descriptor | data\n' + + ' 16 STU // store depth_descriptor for `code`\n' + + ' 16 STU // store depth_descriptor for `data`\n' + + ' 256 STU // store `code` hash\n' + + ' 256 STU // store `data` hash\n' + + '\n' + + ' // Group 3: SHA256 hash of the resulting Builder\n' + + ' ONE HASHEXT_SHA256' + ] + }, + loc: { start: 1019, end: 2666 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 3391, end: 3409 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3447, end: 3454 } + }, + typeArgs: [], + loc: { start: 3447, end: 3454 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 3410, end: 3415 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3417, end: 3420 } + }, + loc: { start: 3410, end: 3420 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3422, end: 3426 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3428, end: 3432 } + }, + loc: { start: 3422, end: 3432 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'data', + loc: { start: 3434, end: 3438 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3440, end: 3444 } + }, + loc: { start: 3434, end: 3444 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 3465, end: 3469 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 3472, end: 3484 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'code', + loc: { start: 3485, end: 3489 } + }, + { + kind: 'var', + name: 'data', + loc: { start: 3491, end: 3495 } + } + ], + loc: { start: 3472, end: 3496 } + }, + loc: { start: 3461, end: 3497 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newAddress', + loc: { start: 3509, end: 3519 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 3520, end: 3525 } + }, + { + kind: 'var', + name: 'hash', + loc: { start: 3527, end: 3531 } + } + ], + loc: { start: 3509, end: 3532 } + }, + loc: { start: 3502, end: 3533 } + } + ] + }, + loc: { start: 3380, end: 3535 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3731, end: 3740 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 3803, end: 3807 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3809, end: 3813 } + }, + loc: { start: 3809, end: 3813 } + }, + initializer: undefined, + loc: { start: 3803, end: 3813 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 3914, end: 3918 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3920, end: 3924 } + }, + loc: { start: 3920, end: 3924 } + }, + initializer: undefined, + loc: { start: 3914, end: 3924 } + } + ], + loc: { start: 3724, end: 3927 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'hasSameBasechainAddress', + loc: { start: 4778, end: 4801 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4837, end: 4841 } + }, + typeArgs: [], + loc: { start: 4837, end: 4841 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'sender', + loc: { start: 4819, end: 4825 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4827, end: 4834 } + }, + typeArgs: [], + loc: { start: 4827, end: 4834 } + }, + loc: { start: 4819, end: 4834 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'senderAddress', + loc: { start: 4852, end: 4865 } + }, + type: undefined, + expression: { + kind: 'field_access', + aggregate: { + kind: 'static_call', + function: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 4868, end: 4883 } + }, + typeArgs: [], + args: [ + { + kind: 'method_call', + self: { + kind: 'var', + name: 'sender', + loc: { start: 4884, end: 4890 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4891, end: 4898 } + }, + typeArgs: [], + args: [], + loc: { start: 4884, end: 4900 } + } + ], + loc: { start: 4868, end: 4901 } + }, + field: { + kind: 'id', + text: 'address', + loc: { start: 4902, end: 4909 } + }, + loc: { start: 4868, end: 4909 } + }, + loc: { start: 4848, end: 4910 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'baseAddress', + loc: { start: 4919, end: 4930 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 4933, end: 4957 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'self', + loc: { start: 4958, end: 4962 } + } + ], + loc: { start: 4933, end: 4963 } + }, + loc: { start: 4915, end: 4964 } + }, + { + kind: 'statement_return', + expression: { + kind: 'op_binary', + op: '==', + left: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'baseAddress', + loc: { start: 4976, end: 4987 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 4988, end: 4992 } + }, + loc: { start: 4976, end: 4992 } + }, + loc: { start: 4976, end: 4994 } + }, + right: { + kind: 'var', + name: 'senderAddress', + loc: { start: 4998, end: 5011 } + }, + loc: { start: 4976, end: 5011 } + }, + loc: { start: 4969, end: 5012 } + } + ] + }, + loc: { start: 4759, end: 5014 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 4808, end: 4817 } + }, + typeArgs: [], + loc: { start: 4808, end: 4817 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractAddress', + loc: { start: 5709, end: 5724 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 5740, end: 5747 } + }, + typeArgs: [], + loc: { start: 5740, end: 5747 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 5725, end: 5726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 5728, end: 5737 } + }, + typeArgs: [], + loc: { start: 5728, end: 5737 } + }, + loc: { start: 5725, end: 5737 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractAddressExt', + loc: { start: 5761, end: 5779 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 5780, end: 5781 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5783, end: 5784 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 5785, end: 5789 } + }, + loc: { start: 5783, end: 5789 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 5791, end: 5792 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 5793, end: 5797 } + }, + loc: { start: 5791, end: 5797 } + } + ], + loc: { start: 5761, end: 5798 } + }, + loc: { start: 5754, end: 5799 } + } + ] + }, + loc: { start: 5698, end: 5801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myAddress', + loc: { start: 6082, end: 6091 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 6095, end: 6102 } + }, + typeArgs: [], + loc: { start: 6095, end: 6102 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYADDR' ] + }, + loc: { start: 6074, end: 6113 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myBalance', + loc: { start: 6454, end: 6463 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6467, end: 6470 } + }, + loc: { start: 6467, end: 6470 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BALANCE FIRST' ] + }, + loc: { start: 6446, end: 6488 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'gasConsumed', + loc: { start: 6880, end: 6891 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 6895, end: 6898 } + }, + loc: { start: 6895, end: 6898 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GASCONSUMED' ] + }, + loc: { start: 6872, end: 6914 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myStorageDue', + loc: { start: 7329, end: 7341 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 7345, end: 7348 } + }, + loc: { start: 7345, end: 7348 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'DUEPAYMENT' ] + }, + loc: { start: 7321, end: 7363 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getStorageFee', + loc: { start: 8517, end: 8530 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8590, end: 8593 } + }, + loc: { start: 8590, end: 8593 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 8531, end: 8536 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8538, end: 8541 } + }, + loc: { start: 8531, end: 8541 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 8543, end: 8547 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8549, end: 8552 } + }, + loc: { start: 8543, end: 8552 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seconds', + loc: { start: 8554, end: 8561 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8563, end: 8566 } + }, + loc: { start: 8554, end: 8566 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 8568, end: 8581 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 8583, end: 8587 } + }, + typeArgs: [], + loc: { start: 8583, end: 8587 } + }, + loc: { start: 8568, end: 8587 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETSTORAGEFEE' ] + }, + loc: { start: 8509, end: 8611 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getComputeFee', + loc: { start: 9734, end: 9747 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9784, end: 9787 } + }, + loc: { start: 9784, end: 9787 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 9748, end: 9755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9757, end: 9760 } + }, + loc: { start: 9748, end: 9760 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 9762, end: 9775 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9777, end: 9781 } + }, + typeArgs: [], + loc: { start: 9777, end: 9781 } + }, + loc: { start: 9762, end: 9781 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEE' ] + }, + loc: { start: 9726, end: 9801 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleComputeFee', + loc: { start: 10689, end: 10708 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10745, end: 10748 } + }, + loc: { start: 10745, end: 10748 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'gasUsed', + loc: { start: 10709, end: 10716 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10718, end: 10721 } + }, + loc: { start: 10709, end: 10721 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 10723, end: 10736 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 10738, end: 10742 } + }, + typeArgs: [], + loc: { start: 10738, end: 10742 } + }, + loc: { start: 10723, end: 10742 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETGASFEESIMPLE' ] + }, + loc: { start: 10681, end: 10768 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getForwardFee', + loc: { start: 12543, end: 12556 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12602, end: 12605 } + }, + loc: { start: 12602, end: 12605 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 12557, end: 12562 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12564, end: 12567 } + }, + loc: { start: 12557, end: 12567 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 12569, end: 12573 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12575, end: 12578 } + }, + loc: { start: 12569, end: 12578 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 12580, end: 12593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 12595, end: 12599 } + }, + typeArgs: [], + loc: { start: 12595, end: 12599 } + }, + loc: { start: 12580, end: 12599 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEE' ] + }, + loc: { start: 12535, end: 12623 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSimpleForwardFee', + loc: { start: 13528, end: 13547 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13593, end: 13596 } + }, + loc: { start: 13593, end: 13596 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'cells', + loc: { start: 13548, end: 13553 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13555, end: 13558 } + }, + loc: { start: 13548, end: 13558 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bits', + loc: { start: 13560, end: 13564 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13566, end: 13569 } + }, + loc: { start: 13560, end: 13569 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 13571, end: 13584 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 13586, end: 13590 } + }, + typeArgs: [], + loc: { start: 13586, end: 13590 } + }, + loc: { start: 13571, end: 13590 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETFORWARDFEESIMPLE' ] + }, + loc: { start: 13520, end: 13620 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getOriginalFwdFee', + loc: { start: 15782, end: 15799 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15835, end: 15838 } + }, + loc: { start: 15835, end: 15838 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'fwdFee', + loc: { start: 15800, end: 15806 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15808, end: 15811 } + }, + loc: { start: 15800, end: 15811 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'isMasterchain', + loc: { start: 15813, end: 15826 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 15828, end: 15832 } + }, + typeArgs: [], + loc: { start: 15828, end: 15832 } + }, + loc: { start: 15813, end: 15832 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'GETORIGINALFWDFEE' ] + }, + loc: { start: 15774, end: 15860 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setGasLimit', + loc: { start: 16541, end: 16552 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'limit', + loc: { start: 16553, end: 16558 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16560, end: 16563 } + }, + loc: { start: 16553, end: 16563 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETGASLIMIT' ] + }, + loc: { start: 16533, end: 16580 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getSeed', + loc: { start: 17350, end: 17357 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17361, end: 17364 } + }, + loc: { start: 17361, end: 17364 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RANDSEED' ] + }, + loc: { start: 17342, end: 17377 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'setSeed', + loc: { start: 18258, end: 18265 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'seed', + loc: { start: 18266, end: 18270 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18272, end: 18275 } + }, + loc: { start: 18266, end: 18275 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SETRAND' ] + }, + loc: { start: 18250, end: 18288 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'myCode', + loc: { start: 18585, end: 18591 } + }, + typeParams: [], + returnType: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 18595, end: 18599 } + }, + loc: { start: 18595, end: 18599 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'MYCODE' ] + }, + loc: { start: 18577, end: 18610 } + } + ] + }, + loc: { start: 171, end: 200 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/debug.tact', + code: '// these are builtin functions, these get special treatment from FunC\n' + + '// hence, no asm here\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Unconditionally throws an exception with an error `code`.\n' + + '///\n' + + '/// Execution of the current context stops, statements after `throw` are not executed, and control is passed to the first `try...catch` block on the call stack. If there is no `try` or `try...catch` block among the calling functions, TVM will terminate the transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun thisWillTerminateAbruptly() {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// fun butThisWont() {\n' + + '/// try {\n' + + '/// throw(1042); // throwing with exit code 1042\n' + + '/// }\n' + + '///\n' + + '/// // ... follow-up logic ...\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw)\n' + + 'native throw(code: Int);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` holds, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwIf(1024, sender() != self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_if)\n' + + 'native throwIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + "/// Similar to `throw()`, but throws an error `code` only if `condition` does **not** hold, i.e. `condition` is equal to `true`. Doesn't throw otherwise.\n" + + '///\n' + + '/// This function is also similar to `require()`, but uses the specified `code` directly instead of generating one based on the given error message `String`.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract Ownership {\n' + + '/// owner: Address;\n' + + '///\n' + + '/// init() {\n' + + '/// self.owner = myAddress();\n' + + '/// }\n' + + '///\n' + + '/// receive() {\n' + + '/// // Check the sender is the owner of the contract,\n' + + "/// // and throw exit code 1024 if it's not\n" + + '/// throwUnless(1024, sender() == self.owner);\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 5: [Integer out of expected range] — Thrown when attempting to specify the `code` outside of 0-65535 range.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#require\n' + + '/// * https://docs.tact-lang.org/book/statements#try-catch\n' + + '///\n' + + '/// [Integer out of expected range]: https://docs.tact-lang.org/book/exit-codes#5\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native throwUnless(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throw()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throw\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrow\n' + + '///\n' + + '@name(throw)\n' + + 'native nativeThrow(code: Int);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwIf()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwif\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowif\n' + + '///\n' + + '@name(throw_if)\n' + + 'native nativeThrowIf(code: Int, condition: Bool);\n' + + '\n' + + '/// Global function. **Deprecated** since Tact 1.6.0.\n' + + '///\n' + + '/// Use `throwUnless()` instead.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#throwunless\n' + + '/// * https://docs.tact-lang.org/ref/core-debug#nativethrowunless\n' + + '///\n' + + '@name(throw_unless)\n' + + 'native nativeThrowUnless(code: Int, condition: Bool);\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throw', + loc: { start: 1107, end: 1112 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 1113, end: 1117 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1113, end: 1122 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 1093, end: 1098 } + } + }, + loc: { start: 1087, end: 1124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwIf', + loc: { start: 2051, end: 2058 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 2059, end: 2063 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2065, end: 2068 } + }, + loc: { start: 2059, end: 2068 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 2070, end: 2079 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 2081, end: 2085 } + }, + typeArgs: [], + loc: { start: 2081, end: 2085 } + }, + loc: { start: 2070, end: 2085 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 2034, end: 2042 } + } + }, + loc: { start: 2028, end: 2087 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'throwUnless', + loc: { start: 3256, end: 3267 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3268, end: 3272 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3274, end: 3277 } + }, + loc: { start: 3268, end: 3277 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3279, end: 3288 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3290, end: 3294 } + }, + typeArgs: [], + loc: { start: 3290, end: 3294 } + }, + loc: { start: 3279, end: 3294 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 3235, end: 3247 } + } + }, + loc: { start: 3229, end: 3296 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrow', + loc: { start: 3534, end: 3545 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3546, end: 3550 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3552, end: 3555 } + }, + loc: { start: 3546, end: 3555 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw', + loc: { start: 3520, end: 3525 } + } + }, + loc: { start: 3514, end: 3557 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowIf', + loc: { start: 3804, end: 3817 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 3818, end: 3822 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3824, end: 3827 } + }, + loc: { start: 3818, end: 3827 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 3829, end: 3838 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3840, end: 3844 } + }, + typeArgs: [], + loc: { start: 3840, end: 3844 } + }, + loc: { start: 3829, end: 3844 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_if', + loc: { start: 3787, end: 3795 } + } + }, + loc: { start: 3781, end: 3846 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeThrowUnless', + loc: { start: 4109, end: 4126 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'code', + loc: { start: 4127, end: 4131 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4133, end: 4136 } + }, + loc: { start: 4127, end: 4136 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'condition', + loc: { start: 4138, end: 4147 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4149, end: 4153 } + }, + typeArgs: [], + loc: { start: 4149, end: 4153 } + }, + loc: { start: 4138, end: 4153 } + } + ], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: 'throw_unless', + loc: { start: 4088, end: 4100 } + } + }, + loc: { start: 4082, end: 4155 } + } + ] + }, + loc: { start: 201, end: 227 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/context.tact', + code: '/// Represents the context of the current message.\n' + + 'struct Context {\n' + + ' /// Indicates whether the received message can\n' + + ' /// [bounce back](https://docs.ton.org/v3/documentation/smart-contracts/message-management/non-bounceable-messages).\n' + + ' bounceable: Bool;\n' + + '\n' + + ' /// Internal address of the sender on the TON Blockchain.\n' + + ' sender: Address;\n' + + '\n' + + ' /// Amount of [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin) in the received message.\n' + + ' value: Int;\n' + + '\n' + + ' /// The remainder of the received message as a `Slice`. It follows the [internal message layout]\n' + + ' /// of TON, starting from the destination `Address` (`MsgAddressInt` in [TL-B notation]).\n' + + ' ///\n' + + ' /// [internal message layout]: https://docs.ton.org/develop/smart-contracts/messages#message-layout\n' + + ' /// [TL-B notation]: https://docs.ton.org/develop/data-formats/tl-b-language\n' + + ' raw: Slice;\n' + + '}\n' + + '\n' + + '/// Returns `Context` struct, which consists of:\n' + + '///\n' + + '/// * `bounceable` — Indicates whether the received message can [bounce back].\n' + + '/// * `sender` — Internal address of the sender on the TON blockchain.\n' + + '/// * `value` — Amount of [nanoToncoin] in the received message.\n' + + '/// * `raw` — The remainder of the received message as a `Slice`. It follows the [internal message layout] of TON, starting from the destination `Address` (`MsgAddressInt` in [TL-B notation]).\n' + + '///\n' + + '/// ```tact\n' + + '/// fun test() {\n' + + '/// let ctx: Context = context();\n' + + '/// require(ctx.value != 68 + 1, "Invalid amount of nanoToncoins, bye!");\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note: If you only need to know who sent the message, use the `sender()` function,\n' + + '/// as it is less gas-consuming.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#context\n' + + '///\n' + + '/// [bounce back]: https://docs.ton.org/v3/documentation/smart-contracts/message-management/non-bounceable-messages\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + '/// [internal message layout]: https://docs.ton.org/develop/smart-contracts/messages#message-layout\n' + + '/// [TL-B notation]: https://docs.ton.org/develop/data-formats/tl-b-language\n' + + '///\n' + + '@name(__tact_context_get)\n' + + 'native context(): Context;\n' + + '\n' + + '/// Returns the `Address` of the sender of the current message.\n' + + '///\n' + + '/// ```tact\n' + + '/// contract MeSee {\n' + + '/// receive() {\n' + + '/// let whoSentMeMessage: Address = sender();\n' + + '/// }\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Note: Behavior is undefined for [getter functions], because they cannot have a sender\n' + + '/// nor can they send messages.\n' + + '///\n' + + '/// Tip: To reduce gas usage, prefer using this function over calling `context().sender`\n' + + '/// when you only need to know the sender of the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#sender\n' + + '///\n' + + '/// [getter functions]: https://docs.tact-lang.org/book/contracts#getter-functions\n' + + '///\n' + + '@name(__tact_context_get_sender)\n' + + 'native sender(): Address;\n' + + '\n' + + '/// Extension function for the `Context` structure.\n' + + '///\n' + + '/// Reads forward fee and returns it as `Int` amount of nanoToncoins.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let fwdFee: Int = context().readForwardFee();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#contextreadforwardfee\n' + + '/// * https://docs.tact-lang.org/ref/core-gas#getoriginalfwdfee\n' + + '///\n' + + 'asm extends fun readForwardFee(self: Context): Int {\n' + + ' // Only the self.raw (Context.raw) is important,\n' + + ' // so all the other fields and loaded values will be dropped by `BLKDROP2`\n' + + ' //\n' + + ' // Context.raw starts at the dest:MsgAddressInt, following this TL-B scheme:\n' + + ' // int_msg_info$0\n' + + ' // ihr_disabled:Bool\n' + + ' // bounce:Bool\n' + + ' // bounced:Bool\n' + + ' // src:MsgAddress\n' + + ' // dest:MsgAddressInt ← here is the start\n' + + ' // value:CurrencyCollection\n' + + ' // ihr_fee:Grams\n' + + ' // fwd_fee:Grams\n' + + ' // created_lt:uint64\n' + + ' // created_at:uint32\n' + + ' // = CommonMsgInfoRelaxed;\n' + + '\n' + + ' LDMSGADDR // load dest:MsgAddressInt\n' + + ' LDGRAMS // load value:CurrencyCollection\n' + + ' ONE\n' + + ' SDSKIPFIRST // skip extra currency collection\n' + + ' LDGRAMS // load ihr_fee\n' + + " LDGRAMS // load fwd_fee, we'll be using this!\n" + + ' DROP // drop remaining Slice (with created_lt and created_at)\n' + + '\n' + + ' // There are 7 entries on the stack — first 3 fields of Context plus 4 loaded ones.\n' + + " // The topmost is fwd_fee, which is the only one we're after, so let's drop 6 entries below:\n" + + ' 6 1 BLKDROP2 // drop the loaded values as well as the first 3 fields of Context\n' + + '\n' + + ' ZERO // not masterchain\n' + + ' GETORIGINALFWDFEE // floor(fwd_fee * 2^16 / (2^16 - first_frac)), where\n' + + ' // first_frac is a value listed in config param 25\n' + + ' // of the blockchain: https://tonviewer.com/config#25\n' + + ' // this instruction effectively multiplies the fwd_fee by 1.5,\n' + + ' // at least for the current value of first_frac, which is 21845\n' + + '}\n', + imports: [], + items: [ + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 58, end: 65 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounceable', + loc: { start: 244, end: 254 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 256, end: 260 } + }, + typeArgs: [], + loc: { start: 256, end: 260 } + }, + initializer: undefined, + loc: { start: 244, end: 260 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'sender', + loc: { start: 329, end: 335 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 337, end: 344 } + }, + typeArgs: [], + loc: { start: 337, end: 344 } + }, + initializer: undefined, + loc: { start: 329, end: 344 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 462, end: 467 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 469, end: 472 } + }, + loc: { start: 469, end: 472 } + }, + initializer: undefined, + loc: { start: 462, end: 472 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'raw', + loc: { start: 867, end: 870 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 872, end: 877 } + }, + loc: { start: 872, end: 877 } + }, + initializer: undefined, + loc: { start: 867, end: 877 } + } + ], + loc: { start: 51, end: 880 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'context', + loc: { start: 2105, end: 2112 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 2116, end: 2123 } + }, + typeArgs: [], + loc: { start: 2116, end: 2123 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_context_get', + loc: { start: 2078, end: 2096 } + } + }, + loc: { start: 2072, end: 2124 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sender', + loc: { start: 2802, end: 2808 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2812, end: 2819 } + }, + typeArgs: [], + loc: { start: 2812, end: 2819 } + }, + params: [], + body: { + kind: 'native_body', + nativeName: { + kind: 'func_id', + text: '__tact_context_get_sender', + loc: { start: 2768, end: 2793 } + } + }, + loc: { start: 2762, end: 2820 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'readForwardFee', + loc: { start: 3226, end: 3240 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3257, end: 3260 } + }, + loc: { start: 3257, end: 3260 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'LDMSGADDR // load dest:MsgAddressInt\n' + + ' LDGRAMS // load value:CurrencyCollection\n' + + ' ONE\n' + + ' SDSKIPFIRST // skip extra currency collection\n' + + ' LDGRAMS // load ihr_fee\n' + + " LDGRAMS // load fwd_fee, we'll be using this!\n" + + ' DROP // drop remaining Slice (with created_lt and created_at)\n' + + '\n' + + ' // There are 7 entries on the stack — first 3 fields of Context plus 4 loaded ones.\n' + + " // The topmost is fwd_fee, which is the only one we're after, so let's drop 6 entries below:\n" + + ' 6 1 BLKDROP2 // drop the loaded values as well as the first 3 fields of Context\n' + + '\n' + + ' ZERO // not masterchain\n' + + ' GETORIGINALFWDFEE // floor(fwd_fee * 2^16 / (2^16 - first_frac)), where\n' + + ' // first_frac is a value listed in config param 25\n' + + ' // of the blockchain: https://tonviewer.com/config#25\n' + + ' // this instruction effectively multiplies the fwd_fee by 1.5,\n' + + ' // at least for the current value of first_frac, which is 21845' + ] + }, + loc: { start: 3210, end: 4831 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 3247, end: 3254 } + }, + typeArgs: [], + loc: { start: 3247, end: 3254 } + } + } + ] + }, + loc: { start: 228, end: 256 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + loc: { start: 257, end: 285 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { + kind: 'null', + loc: { start: 2507, end: 2511 } + }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { + kind: 'null', + loc: { start: 2598, end: 2602 } + }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { + kind: 'null', + loc: { start: 2736, end: 2740 } + }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { + kind: 'null', + loc: { start: 3639, end: 3643 } + }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'send', + loc: { start: 6219, end: 6223 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { + kind: 'null', + loc: { start: 9596, end: 9600 } + }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + loc: { start: 286, end: 311 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/config.tact', + code: '/// Loads a [configuration parameter] of TON Blockchain by its `id` number.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#getconfigparam\n' + + '///\n' + + '/// [configuration parameter]: https://docs.ton.org/develop/howto/blockchain-configs\n' + + '///\n' + + 'asm fun getConfigParam(id: Int): Cell? { CONFIGOPTPARAM }\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'getConfigParam', + loc: { start: 254, end: 268 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 283, end: 284 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 279, end: 283 } + }, + loc: { start: 279, end: 283 } + } + ], + loc: { start: 283, end: 284 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'id', + loc: { start: 269, end: 271 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 273, end: 276 } + }, + loc: { start: 273, end: 276 } + }, + loc: { start: 269, end: 276 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'CONFIGOPTPARAM' ] + }, + loc: { start: 246, end: 303 } + } + ] + }, + loc: { start: 312, end: 339 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/base.tact', + code: '/// Describes the base logic that is available in all contracts and traits by default.\n' + + '///\n' + + '/// This trait is implicitly inherited by every other contract and trait.\n' + + '/// It contains a number of the most useful internal functions for any kind of contract,\n' + + '/// and a constant `self.storageReserve` aimed at advanced users of Tact.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-base/\n' + + 'trait BaseTrait {\n' + + ' /// The amount of nanoToncoins to reserve before forwarding a message with\n' + + ' /// `SendRemainingBalance` mode. Default is 0 (no reserve).\n' + + ' ///\n' + + ' /// ```tact\n' + + ' /// contract AllYourStorageBelongsToUs {\n' + + ' /// // This would change the behavior of `self.forward()` function,\n' + + ' /// // causing it to try reserving this amount of nanoToncoins before\n' + + ' /// // forwarding a message with `SendRemainingBalance` mode\n' + + ' /// override const storageReserve: Int = ton("0.1");\n' + + ' /// }\n' + + ' /// ```\n' + + ' ///\n' + + ' /// See: https://docs.tact-lang.org/ref/core-base#self-forward\n' + + ' ///\n' + + ' virtual const storageReserve: Int = 0;\n' + + '\n' + + ' /// Sends a bounceable message back to the sender of the current message.\n' + + ' /// An alias function to calling the `self.forward()` function with\n' + + ' /// the following arguments:\n' + + ' ///\n' + + ' /// ```tact\n' + + ' /// self.forward(sender(), body, true, null);\n' + + ' /// ↑ ↑ ↑ ↑\n' + + ' /// | | | init: StateInit?\n' + + ' /// | | bounce: Bool\n' + + ' /// | body: Cell?\n' + + ' /// to: Address\n' + + ' /// ```\n' + + ' ///\n' + + ' /// See: https://docs.tact-lang.org/ref/core-base#self-forward\n' + + ' ///\n' + + ' virtual inline fun reply(body: Cell?) {\n' + + ' self.forward(sender(), body, true, null);\n' + + ' }\n' + + '\n' + + ' /// Sends a non-bounceable message back to the sender of the current message.\n' + + ' /// An alias function to calling the `self.forward()` function with\n' + + ' /// the following arguments:\n' + + ' ///\n' + + ' /// ```tact\n' + + ' /// self.forward(sender(), body, false, null);\n' + + ' /// ↑ ↑ ↑ ↑\n' + + ' /// | | | init: StateInit?\n' + + ' /// | | bounce: Bool\n' + + ' /// | body: Cell?\n' + + ' /// to: Address\n' + + ' /// ```\n' + + ' ///\n' + + ' /// See: https://docs.tact-lang.org/ref/core-base#self-forward\n' + + ' ///\n' + + ' virtual inline fun notify(body: Cell?) {\n' + + ' self.forward(sender(), body, false, null);\n' + + ' }\n' + + '\n' + + ' /// Queues the message (bounceable or non-bounceable) to be sent to the specified address `to`.\n' + + ' /// Optionally, you may provide a `body` of the message and the `init` package with `initOf`.\n' + + ' ///\n' + + ' /// When `self.storageReserve` constant is overwritten to be greater than zero, before sending a\n' + + ' /// message it also tries to reserve the `self.storageReserve` amount of nanoToncoins from the\n' + + ' /// remaining balance before making the send in the `SendRemainingBalance` (128) mode.\n' + + ' ///\n' + + ' /// In case reservation attempt fails and in the default case without the attempt, the message\n' + + ' /// is sent with the `SendRemainingValue` (64) mode instead.\n' + + ' ///\n' + + ' /// > Note that `self.forward()` never sends additional nanoToncoins on top of what’s available on the balance.\n' + + ' /// > To be able to send more nanoToncoins with a single message, use the the `send` function.\n' + + ' ///\n' + + ' /// See: https://docs.tact-lang.org/ref/core-base#self-forward\n' + + ' ///\n' + + ' virtual fun forward(to: Address, body: Cell?, bounce: Bool, init: StateInit?) {\n' + + ' let code: Cell? = null;\n' + + ' let data: Cell? = null;\n' + + ' if (init != null) {\n' + + ' let init2: StateInit = init!!;\n' + + ' code = init2.code;\n' + + ' data = init2.data;\n' + + ' }\n' + + '\n' + + ' // Lock storage if needed\n' + + ' if (self.storageReserve > 0) { // Optimized in compile-time\n' + + ' let ctx: Context = context();\n' + + ' let balance: Int = myBalance();\n' + + ' let balanceBeforeMessage: Int = balance - ctx.value;\n' + + ' if (balanceBeforeMessage < self.storageReserve) {\n' + + ' nativeReserve(self.storageReserve, ReserveExact);\n' + + ' send(SendParameters {\n' + + ' bounce,\n' + + ' to,\n' + + ' value: 0,\n' + + ' mode: SendRemainingBalance | SendIgnoreErrors,\n' + + ' body,\n' + + ' code,\n' + + ' data,\n' + + ' });\n' + + ' return;\n' + + ' }\n' + + ' }\n' + + '\n' + + ' // Just send with remaining balance\n' + + ' send(SendParameters {\n' + + ' bounce,\n' + + ' to,\n' + + ' value: 0,\n' + + ' mode: SendRemainingValue | SendIgnoreErrors,\n' + + ' body,\n' + + ' code,\n' + + ' data,\n' + + ' });\n' + + ' }\n' + + '}\n', + imports: [], + items: [ + { + kind: 'trait', + name: { + kind: 'type_id', + text: 'BaseTrait', + loc: { start: 389, end: 398 } + }, + traits: [], + attributes: [], + declarations: [ + { + kind: 'field_const', + virtual: true, + override: false, + body: { + kind: 'constant', + name: { + kind: 'id', + text: 'storageReserve', + loc: { start: 1020, end: 1034 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1036, end: 1039 } + }, + loc: { start: 1036, end: 1039 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1042, end: 1043 } + } + }, + loc: { start: 1006, end: 1044 } + } + }, + { + kind: 'method', + mutates: false, + virtual: true, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'reply', + loc: { start: 1652, end: 1657 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 1658, end: 1662 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 1668, end: 1669 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 1664, end: 1668 } + }, + loc: { start: 1664, end: 1668 } + } + ], + loc: { start: 1668, end: 1669 } + }, + loc: { start: 1658, end: 1669 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1681, end: 1685 } + }, + method: { + kind: 'id', + text: 'forward', + loc: { start: 1686, end: 1693 } + }, + typeArgs: [], + args: [ + { + kind: 'static_call', + function: { + kind: 'id', + text: 'sender', + loc: { start: 1694, end: 1700 } + }, + typeArgs: [], + args: [], + loc: { start: 1694, end: 1702 } + }, + { + kind: 'var', + name: 'body', + loc: { start: 1704, end: 1708 } + }, + { + kind: 'boolean', + value: true, + loc: { start: 1710, end: 1714 } + }, + { + kind: 'null', + loc: { start: 1716, end: 1720 } + } + ], + loc: { start: 1681, end: 1721 } + }, + loc: { start: 1681, end: 1722 } + } + ] + }, + loc: { start: 1633, end: 1728 } + } + }, + { + kind: 'method', + mutates: false, + virtual: true, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'notify', + loc: { start: 2341, end: 2347 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 2348, end: 2352 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2358, end: 2359 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2354, end: 2358 } + }, + loc: { start: 2354, end: 2358 } + } + ], + loc: { start: 2358, end: 2359 } + }, + loc: { start: 2348, end: 2359 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 2371, end: 2375 } + }, + method: { + kind: 'id', + text: 'forward', + loc: { start: 2376, end: 2383 } + }, + typeArgs: [], + args: [ + { + kind: 'static_call', + function: { + kind: 'id', + text: 'sender', + loc: { start: 2384, end: 2390 } + }, + typeArgs: [], + args: [], + loc: { start: 2384, end: 2392 } + }, + { + kind: 'var', + name: 'body', + loc: { start: 2394, end: 2398 } + }, + { + kind: 'boolean', + value: false, + loc: { start: 2400, end: 2405 } + }, + { + kind: 'null', + loc: { start: 2407, end: 2411 } + } + ], + loc: { start: 2371, end: 2412 } + }, + loc: { start: 2371, end: 2413 } + } + ] + }, + loc: { start: 2322, end: 2419 } + } + }, + { + kind: 'method', + mutates: false, + virtual: true, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forward', + loc: { start: 3412, end: 3419 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 3420, end: 3422 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3424, end: 3431 } + }, + typeArgs: [], + loc: { start: 3424, end: 3431 } + }, + loc: { start: 3420, end: 3431 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 3433, end: 3437 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3443, end: 3444 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3439, end: 3443 } + }, + loc: { start: 3439, end: 3443 } + } + ], + loc: { start: 3443, end: 3444 } + }, + loc: { start: 3433, end: 3444 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3446, end: 3452 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3454, end: 3458 } + }, + typeArgs: [], + loc: { start: 3454, end: 3458 } + }, + loc: { start: 3446, end: 3458 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'init', + loc: { start: 3460, end: 3464 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3475, end: 3476 } + }, + typeArgs: [ + { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3466, end: 3475 } + }, + typeArgs: [], + loc: { start: 3466, end: 3475 } + } + ], + loc: { start: 3475, end: 3476 } + }, + loc: { start: 3460, end: 3476 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'code', + loc: { start: 3492, end: 3496 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3502, end: 3503 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3498, end: 3502 } + }, + loc: { start: 3498, end: 3502 } + } + ], + loc: { start: 3502, end: 3503 } + }, + expression: { + kind: 'null', + loc: { start: 3506, end: 3510 } + }, + loc: { start: 3488, end: 3511 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'data', + loc: { start: 3524, end: 3528 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3534, end: 3535 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3530, end: 3534 } + }, + loc: { start: 3530, end: 3534 } + } + ], + loc: { start: 3534, end: 3535 } + }, + expression: { + kind: 'null', + loc: { start: 3538, end: 3542 } + }, + loc: { start: 3520, end: 3543 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '!=', + left: { + kind: 'var', + name: 'init', + loc: { start: 3556, end: 3560 } + }, + right: { + kind: 'null', + loc: { start: 3564, end: 3568 } + }, + loc: { start: 3556, end: 3568 } + }, + trueStatements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'init2', + loc: { start: 3588, end: 3593 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 3595, end: 3604 } + }, + typeArgs: [], + loc: { start: 3595, end: 3604 } + }, + expression: { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'var', + name: 'init', + loc: { start: 3607, end: 3611 } + }, + loc: { start: 3607, end: 3613 } + }, + loc: { start: 3584, end: 3614 } + }, + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'code', + loc: { start: 3627, end: 3631 } + }, + expression: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'init2', + loc: { start: 3634, end: 3639 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 3640, end: 3644 } + }, + loc: { start: 3634, end: 3644 } + }, + loc: { start: 3627, end: 3645 } + }, + { + kind: 'statement_assign', + path: { + kind: 'var', + name: 'data', + loc: { start: 3658, end: 3662 } + }, + expression: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'init2', + loc: { start: 3665, end: 3670 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 3671, end: 3675 } + }, + loc: { start: 3665, end: 3675 } + }, + loc: { start: 3658, end: 3676 } + } + ], + falseStatements: undefined, + loc: { start: 3552, end: 3686 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '>', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 3734, end: 3738 } + }, + field: { + kind: 'id', + text: 'storageReserve', + loc: { start: 3739, end: 3753 } + }, + loc: { start: 3734, end: 3753 } + }, + right: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 3756, end: 3757 } + }, + loc: { start: 3734, end: 3757 } + }, + trueStatements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'ctx', + loc: { start: 3806, end: 3809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Context', + loc: { start: 3811, end: 3818 } + }, + typeArgs: [], + loc: { start: 3811, end: 3818 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'context', + loc: { start: 3821, end: 3828 } + }, + typeArgs: [], + args: [], + loc: { start: 3821, end: 3830 } + }, + loc: { start: 3802, end: 3831 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'balance', + loc: { start: 3848, end: 3855 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3857, end: 3860 } + }, + loc: { start: 3857, end: 3860 } + }, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'myBalance', + loc: { start: 3863, end: 3872 } + }, + typeArgs: [], + args: [], + loc: { start: 3863, end: 3874 } + }, + loc: { start: 3844, end: 3875 } + }, + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'balanceBeforeMessage', + loc: { start: 3892, end: 3912 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3914, end: 3917 } + }, + loc: { start: 3914, end: 3917 } + }, + expression: { + kind: 'op_binary', + op: '-', + left: { + kind: 'var', + name: 'balance', + loc: { start: 3920, end: 3927 } + }, + right: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'ctx', + loc: { start: 3930, end: 3933 } + }, + field: { + kind: 'id', + text: 'value', + loc: { start: 3934, end: 3939 } + }, + loc: { start: 3930, end: 3939 } + }, + loc: { start: 3920, end: 3939 } + }, + loc: { start: 3888, end: 3940 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '<', + left: { + kind: 'var', + name: 'balanceBeforeMessage', + loc: { start: 3957, end: 3977 } + }, + right: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { start: 3980, end: 3984 } + }, + field: { + kind: 'id', + text: 'storageReserve', + loc: { start: 3985, end: 3999 } + }, + loc: { start: 3980, end: 3999 } + }, + loc: { start: 3957, end: 3999 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'nativeReserve', + loc: { + start: 4019, + end: 4032 + } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'self', + loc: { + start: 4033, + end: 4037 + } + }, + field: { + kind: 'id', + text: 'storageReserve', + loc: { + start: 4038, + end: 4052 + } + }, + loc: { + start: 4033, + end: 4052 + } + }, + { + kind: 'var', + name: 'ReserveExact', + loc: { + start: 4054, + end: 4066 + } + } + ], + loc: { start: 4019, end: 4067 } + }, + loc: { start: 4019, end: 4068 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'send', + loc: { + start: 4085, + end: 4089 + } + }, + typeArgs: [], + args: [ + { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'SendParameters', + loc: { + start: 4090, + end: 4104 + } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'bounce', + loc: { + start: 4127, + end: 4133 + } + }, + initializer: { + kind: 'var', + name: 'bounce', + loc: { + start: 4127, + end: 4133 + } + }, + loc: { + start: 4127, + end: 4133 + } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'to', + loc: { + start: 4155, + end: 4157 + } + }, + initializer: { + kind: 'var', + name: 'to', + loc: { + start: 4155, + end: 4157 + } + }, + loc: { + start: 4155, + end: 4157 + } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'value', + loc: { + start: 4179, + end: 4184 + } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { + start: 4186, + end: 4187 + } + }, + loc: { + start: 4179, + end: 4187 + } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'mode', + loc: { + start: 4209, + end: 4213 + } + }, + initializer: { + kind: 'op_binary', + op: '|', + left: { + kind: 'var', + name: 'SendRemainingBalance', + loc: { + start: 4215, + end: 4235 + } + }, + right: { + kind: 'var', + name: 'SendIgnoreErrors', + loc: { + start: 4238, + end: 4254 + } + }, + loc: { + start: 4215, + end: 4254 + } + }, + loc: { + start: 4209, + end: 4254 + } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'body', + loc: { + start: 4276, + end: 4280 + } + }, + initializer: { + kind: 'var', + name: 'body', + loc: { + start: 4276, + end: 4280 + } + }, + loc: { + start: 4276, + end: 4280 + } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'code', + loc: { + start: 4302, + end: 4306 + } + }, + initializer: { + kind: 'var', + name: 'code', + loc: { + start: 4302, + end: 4306 + } + }, + loc: { + start: 4302, + end: 4306 + } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'data', + loc: { + start: 4328, + end: 4332 + } + }, + initializer: { + kind: 'var', + name: 'data', + loc: { + start: 4328, + end: 4332 + } + }, + loc: { + start: 4328, + end: 4332 + } + } + ], + loc: { + start: 4090, + end: 4351 + } + } + ], + loc: { start: 4085, end: 4352 } + }, + loc: { start: 4085, end: 4353 } + }, + { + kind: 'statement_return', + expression: undefined, + loc: { start: 4370, end: 4377 } + } + ], + falseStatements: undefined, + loc: { start: 3953, end: 4391 } + } + ], + falseStatements: undefined, + loc: { start: 3730, end: 4401 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'send', + loc: { start: 4455, end: 4459 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 4460, end: 4474 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'bounce', + loc: { + start: 4489, + end: 4495 + } + }, + initializer: { + kind: 'var', + name: 'bounce', + loc: { + start: 4489, + end: 4495 + } + }, + loc: { start: 4489, end: 4495 } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'to', + loc: { + start: 4509, + end: 4511 + } + }, + initializer: { + kind: 'var', + name: 'to', + loc: { + start: 4509, + end: 4511 + } + }, + loc: { start: 4509, end: 4511 } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'value', + loc: { + start: 4525, + end: 4530 + } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { + start: 4532, + end: 4533 + } + }, + loc: { start: 4525, end: 4533 } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'mode', + loc: { + start: 4547, + end: 4551 + } + }, + initializer: { + kind: 'op_binary', + op: '|', + left: { + kind: 'var', + name: 'SendRemainingValue', + loc: { + start: 4553, + end: 4571 + } + }, + right: { + kind: 'var', + name: 'SendIgnoreErrors', + loc: { + start: 4574, + end: 4590 + } + }, + loc: { + start: 4553, + end: 4590 + } + }, + loc: { start: 4547, end: 4590 } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'body', + loc: { + start: 4604, + end: 4608 + } + }, + initializer: { + kind: 'var', + name: 'body', + loc: { + start: 4604, + end: 4608 + } + }, + loc: { start: 4604, end: 4608 } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'code', + loc: { + start: 4622, + end: 4626 + } + }, + initializer: { + kind: 'var', + name: 'code', + loc: { + start: 4622, + end: 4626 + } + }, + loc: { start: 4622, end: 4626 } + }, + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'data', + loc: { + start: 4640, + end: 4644 + } + }, + initializer: { + kind: 'var', + name: 'data', + loc: { + start: 4640, + end: 4644 + } + }, + loc: { start: 4640, end: 4644 } + } + ], + loc: { start: 4460, end: 4655 } + } + ], + loc: { start: 4455, end: 4656 } + }, + loc: { start: 4455, end: 4657 } + } + ] + }, + loc: { start: 3400, end: 4663 } + } + } + ], + loc: { start: 383, end: 4665 } + } + ] + }, + loc: { start: 340, end: 365 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/address.tact', + code: '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + "/// let a: Address = myAddress(); // let's assume we're in a basechain\n" + + '/// let a2: Address = a.asSlice().asAddress(0); // so the chain ID is 0\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 136: [Invalid standard address] — Thrown when the given `Slice` contains an invalid\n' + + '/// tag prefix (not `0b100`) or an invalid account ID length (not 256 bits).\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + '/// [Invalid standard address]: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'extends fun asAddress(self: Slice, chain: Int): Address {\n' + + ' // 11 bits for the prefix,\n' + + ' // 256 bits for the address itself\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.bits() == 267);\n' + + '\n' + + ' if (chain == -1) {\n' + + ' // 1279 = 0b100_1111_1111,\n' + + ' // i.e. internal address prefix and chain ID -1\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(11) == 1279);\n' + + ' } else {\n' + + ' // Only check the correct internal address prefix,\n' + + ' // but do not verify the chain ID\n' + + ' throwUnless(TactExitCodeInvalidStandardAddress, self.preloadUint(3) == 4);\n' + + ' }\n' + + '\n' + + ' // Proceed with the cast\n' + + ' return self.asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Extension function for the `Slice` type. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Unsafely casts the `Slice` to an `Address` and returns it. The inverse of `Address.asSlice()`.\n' + + '///\n' + + '/// This function does **not** perform any checks on the contents of the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let a2: Address = a.asSlice().asAddressUnsafe();\n' + + '///\n' + + '/// a == a2; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// Use it only if you want to optimize the code for gas and can guarantee in advance that the `Slice` contains the data of an `Address`.\n' + + '///\n' + + '/// Otherwise, use a safer but more gas-expensive `Slice.asAddress()` function.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddress\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '///\n' + + 'asm extends fun asAddressUnsafe(self: Slice): Address {}\n' + + '\n' + + '/// Extension function for the `Address` type.\n' + + '///\n' + + '/// Casts `self` back to the underlying `Slice` and returns it. The inverse of `Slice.asAddressUnsafe()`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let a: Address = myAddress();\n' + + '/// let fizz: Slice = beginCell().storeAddress(a).asSlice();\n' + + '/// let buzz: Slice = a.asSlice(); // cheap, unlike the previous statement\n' + + '///\n' + + '/// fizz == buzz; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#addressasslice\n' + + '/// * https://docs.tact-lang.org/ref/core-cells#sliceasaddressunsafe\n' + + '///\n' + + 'asm extends fun asSlice(self: Address): Slice {}\n' + + '\n' + + '/// Global function.\n' + + '///\n' + + '/// Creates a new `Address` based on the `chain` ID and the SHA-256 encoded `hash` value (account ID).\n' + + '///\n' + + '/// This function tries to resolve constant values in compile-time whenever possible.\n' + + '///\n' + + '/// Attempts to specify an uncommon `chain` ID (not -1 or 0) that can be detected in compile-time will result in a compilation error.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let oldTonFoundationAddr: Address =\n' + + '/// newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);\n' + + '/// // ↑ ↑\n' + + "/// // | sha-256 hash of contract's init package (StateInit)\n" + + '/// // chain id: 0 is a workchain, -1 is a masterchain\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#newaddress\n' + + '///\n' + + 'inline fun newAddress(chain: Int, hash: Int): Address {\n' + + ' return beginCell()\n' + + ' .storeUint(0b10_0, 3)\n' + + ' .storeInt(chain, 8)\n' + + ' .storeUint(hash, 256)\n' + + ' .endCell()\n' + + ' .asSlice()\n' + + ' .asAddressUnsafe();\n' + + '}\n' + + '\n' + + '/// Struct representing the standard address on TON Blockchain with signed 8-bit `workchain` ID and an unsigned 256-bit `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// At the moment, only `workchain` IDs used on TON are 0 of the basechain and -1 of the masterchain.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L105-L106\n' + + '///\n' + + 'struct StdAddress {\n' + + ' workchain: Int as int8;\n' + + ' address: Int as uint256;\n' + + '}\n' + + '\n' + + '/// Struct representing the address of variable length with signed 32-bit `workchain` ID and a `Slice` containing unsigned `address` in the specified `workchain`. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Variable-length addresses are intended for future extensions, and while validators must be ready to accept them in inbound messages, the standard (non-variable) addresses are used whenever possible.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '/// * https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb#L107-L108\n' + + '///\n' + + 'struct VarAddress {\n' + + ' workchain: Int as int32;\n' + + ' address: Slice;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address into the `StdAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let addr = address("EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2");\n' + + '/// let parsedAddr = parseStdAddress(addr.asSlice());\n' + + '///\n' + + '/// parsedAddr.workchain; // 0\n' + + '/// parsedAddr.address; // 107...287\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsestdaddress\n' + + '///\n' + + 'asm fun parseStdAddress(slice: Slice): StdAddress { REWRITESTDADDR }\n' + + '\n' + + '/// Global function. Available since Tact 1.5.0.\n' + + '///\n' + + '/// Converts a `slice` containing an address of variable length into the `VarAddress` Struct and returns it.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let varAddrSlice = beginCell()\n' + + '/// .storeUint(6, 3) // to recognize the following as a VarAddress\n' + + '/// .storeUint(123, 9) // make address occupy 123 bits\n' + + '/// .storeUint(234, 32) // specify workchain ID of 234\n' + + '/// .storeUint(345, 123) // specify address of 345\n' + + '/// .asSlice();\n' + + '/// let parsedVarAddr = parseVarAddress(varAddrSlice);\n' + + '///\n' + + '/// parsedVarAddr.workchain; // 234\n' + + '/// parsedVarAddr.address; // CS{Cell{002...2b3} bits: 44..167; refs: 0..0}\n' + + '/// parsedVarAddr.address.loadUint(123); // 345\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-addresses#parsevaraddress\n' + + '///\n' + + 'asm fun parseVarAddress(slice: Slice): VarAddress { REWRITEVARADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type.\n' + + '///\n' + + '/// Loads and returns an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s: Slice = beginCell().storeAddress(myAddress()).asSlice();\n' + + '/// let fizz: Address = s.loadAddress();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to load an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to load more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceloadaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm(-> 1 0) extends mutates fun loadAddress(self: Slice): Address { LDMSGADDR }\n' + + '\n' + + '/// Extension mutation function for the `Slice` type. Available since Tact 1.6.2.\n' + + '///\n' + + '/// Skips an `Address` from the `Slice`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let s1: Slice = beginCell()\n' + + '/// .storeAddress(myAddress())\n' + + '/// .storeUint(42, 32)\n' + + '/// .asSlice();\n' + + '///\n' + + '/// s1.skipAddress();\n' + + '/// let fizz: Int = s1.loadUint(32); // 42\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + "/// * 8: [Cell overflow] — Thrown when attempting to skip an `Address` when `Slice` doesn't contain it.\n" + + '/// * 9: [Cell underflow] — Thrown when attempting to skip more data than `Slice` contains.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#sliceskipaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '/// [Cell underflow]: https://docs.tact-lang.org/book/exit-codes#9\n' + + '///\n' + + 'asm extends mutates fun skipAddress(self: Slice) { LDMSGADDR NIP }\n' + + '\n' + + '/// Extension function for the `Builder` type.\n' + + '///\n' + + '/// Stores the `address` in the copy of the `Builder`. Returns that copy.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let b: Builder = beginCell();\n' + + '/// let fizz: Builder = b.storeAddress(myAddress());\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 8: [Cell overflow] — Thrown when attempting to store an `address` into the `Builder` when it cannot fit it.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-cells#builderstoreaddress\n' + + '///\n' + + '/// [Cell overflow]: https://docs.tact-lang.org/book/exit-codes#8\n' + + '///\n' + + 'asm extends fun storeAddress(self: Builder, address: Address): Builder { STSLICER }\n' + + '\n' + + '/// Struct representing a basechain address. Available since Tact 1.6.0.\n' + + '///\n' + + '/// A basechain address (workchain 0) can be either empty (null hash) or contain a 256-bit hash value.\n' + + '///\n' + + 'struct BasechainAddress {\n' + + ' hash: Int?;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Creates and returns an empty basechain address with a null hash.\n' + + '///\n' + + '/// When serialized, an empty basechain address is represented as `addr_none`.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let emptyAddr: BasechainAddress = emptyBasechainAddress();\n' + + '/// emptyAddr.hash == null; // true\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + 'inline fun emptyBasechainAddress(): BasechainAddress {\n' + + ' return BasechainAddress { hash: null };\n' + + '}\n' + + '\n' + + '/// Global f'... 4363 more characters, + imports: [], + items: [ + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddress', + loc: { start: 998, end: 1007 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 1034, end: 1041 } + }, + typeArgs: [], + loc: { start: 1034, end: 1041 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 1021, end: 1026 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1028, end: 1031 } + }, + loc: { start: 1021, end: 1031 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1118, end: 1129 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1130, end: 1164 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1166, end: 1170 } + }, + method: { + kind: 'id', + text: 'bits', + loc: { start: 1171, end: 1175 } + }, + typeArgs: [], + args: [], + loc: { start: 1166, end: 1177 } + }, + right: { + kind: 'number', + base: '10', + value: 267n, + loc: { start: 1181, end: 1184 } + }, + loc: { start: 1166, end: 1184 } + } + ], + loc: { start: 1118, end: 1185 } + }, + loc: { start: 1118, end: 1186 } + }, + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'var', + name: 'chain', + loc: { start: 1196, end: 1201 } + }, + right: { + kind: 'op_unary', + op: '-', + operand: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1206, end: 1207 } + }, + loc: { start: 1205, end: 1207 } + }, + loc: { start: 1196, end: 1207 } + }, + trueStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1310, end: 1321 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1322, end: 1356 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { + start: 1358, + end: 1362 + } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { + start: 1363, + end: 1374 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 11n, + loc: { + start: 1375, + end: 1377 + } + } + ], + loc: { start: 1358, end: 1378 } + }, + right: { + kind: 'number', + base: '10', + value: 1279n, + loc: { start: 1382, end: 1386 } + }, + loc: { start: 1358, end: 1386 } + } + ], + loc: { start: 1310, end: 1387 } + }, + loc: { start: 1310, end: 1388 } + } + ], + falseStatements: [ + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'throwUnless', + loc: { start: 1511, end: 1522 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1523, end: 1557 } + }, + { + kind: 'op_binary', + op: '==', + left: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { + start: 1559, + end: 1563 + } + }, + method: { + kind: 'id', + text: 'preloadUint', + loc: { + start: 1564, + end: 1575 + } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 3n, + loc: { + start: 1576, + end: 1577 + } + } + ], + loc: { start: 1559, end: 1578 } + }, + right: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 1582, end: 1583 } + }, + loc: { start: 1559, end: 1583 } + } + ], + loc: { start: 1511, end: 1584 } + }, + loc: { start: 1511, end: 1585 } + } + ], + loc: { start: 1192, end: 1591 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 1633, end: 1637 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 1638, end: 1653 } + }, + typeArgs: [], + args: [], + loc: { start: 1633, end: 1655 } + }, + loc: { start: 1626, end: 1656 } + } + ] + }, + loc: { start: 986, end: 1658 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 1014, end: 1019 } + }, + loc: { start: 1014, end: 1019 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 2554, end: 2569 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 2584, end: 2591 } + }, + typeArgs: [], + loc: { start: 2584, end: 2591 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 2538, end: 2594 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 2576, end: 2581 } + }, + loc: { start: 2576, end: 2581 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'asSlice', + loc: { start: 3188, end: 3195 } + }, + typeParams: [], + returnType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 3212, end: 3217 } + }, + loc: { start: 3212, end: 3217 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ '' ] + }, + loc: { start: 3172, end: 3220 } + } + }, + selfType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3202, end: 3209 } + }, + typeArgs: [], + loc: { start: 3202, end: 3209 } + } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newAddress', + loc: { start: 4029, end: 4039 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 4064, end: 4071 } + }, + typeArgs: [], + loc: { start: 4064, end: 4071 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'chain', + loc: { start: 4040, end: 4045 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4047, end: 4050 } + }, + loc: { start: 4040, end: 4050 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 4052, end: 4056 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4058, end: 4061 } + }, + loc: { start: 4052, end: 4061 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 4085, end: 4094 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4096 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4106, end: 4115 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 4n, + loc: { start: 4116, end: 4122 } + }, + { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 4124, end: 4125 } + } + ], + loc: { start: 4085, end: 4126 } + }, + method: { + kind: 'id', + text: 'storeInt', + loc: { start: 4136, end: 4144 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'chain', + loc: { start: 4145, end: 4150 } + }, + { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 4152, end: 4153 } + } + ], + loc: { start: 4085, end: 4154 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 4164, end: 4173 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 4174, end: 4178 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 4180, end: 4183 } + } + ], + loc: { start: 4085, end: 4184 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 4194, end: 4201 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4203 } + }, + method: { + kind: 'id', + text: 'asSlice', + loc: { start: 4213, end: 4220 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4222 } + }, + method: { + kind: 'id', + text: 'asAddressUnsafe', + loc: { start: 4232, end: 4247 } + }, + typeArgs: [], + args: [], + loc: { start: 4085, end: 4249 } + }, + loc: { start: 4078, end: 4250 } + } + ] + }, + loc: { start: 4018, end: 4252 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 4729, end: 4739 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 4746, end: 4755 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 8, + loc: { start: 4757, end: 4768 } + }, + loc: { start: 4757, end: 4760 } + }, + initializer: undefined, + loc: { start: 4746, end: 4768 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 4774, end: 4781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'unsigned', + width: 256, + loc: { start: 4783, end: 4797 } + }, + loc: { start: 4783, end: 4786 } + }, + initializer: undefined, + loc: { start: 4774, end: 4797 } + } + ], + loc: { start: 4722, end: 4800 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 5381, end: 5391 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 5398, end: 5407 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 32, + loc: { start: 5409, end: 5421 } + }, + loc: { start: 5409, end: 5412 } + }, + initializer: undefined, + loc: { start: 5398, end: 5421 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'address', + loc: { start: 5427, end: 5434 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 5436, end: 5441 } + }, + loc: { start: 5436, end: 5441 } + }, + initializer: undefined, + loc: { start: 5427, end: 5441 } + } + ], + loc: { start: 5374, end: 5444 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseStdAddress', + loc: { start: 5946, end: 5961 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StdAddress', + loc: { start: 5977, end: 5987 } + }, + typeArgs: [], + loc: { start: 5977, end: 5987 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 5962, end: 5967 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5969, end: 5974 } + }, + loc: { start: 5962, end: 5974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR' ] + }, + loc: { start: 5938, end: 6006 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'parseVarAddress', + loc: { start: 6898, end: 6913 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'VarAddress', + loc: { start: 6929, end: 6939 } + }, + typeArgs: [], + loc: { start: 6929, end: 6939 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'slice', + loc: { start: 6914, end: 6919 } + }, + type: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6921, end: 6926 } + }, + loc: { start: 6914, end: 6926 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITEVARADDR' ] + }, + loc: { start: 6890, end: 6958 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'loadAddress', + loc: { start: 7707, end: 7718 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 7733, end: 7740 } + }, + typeArgs: [], + loc: { start: 7733, end: 7740 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { + args: [], + ret: [ + { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 7682, end: 7683 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 7684, end: 7685 } + } + ] + }, + instructions: [ 'LDMSGADDR' ] + }, + loc: { start: 7675, end: 7754 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 7725, end: 7730 } + }, + loc: { start: 7725, end: 7730 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: true, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'skipAddress', + loc: { start: 8601, end: 8612 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LDMSGADDR NIP' ] + }, + loc: { start: 8577, end: 8643 } + } + }, + selfType: { + kind: 'TySlice', + format: { + kind: 'SFDefault', + loc: { start: 8619, end: 8624 } + }, + loc: { start: 8619, end: 8624 } + } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeAddress', + loc: { start: 9222, end: 9234 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 9269, end: 9276 } + }, + loc: { start: 9269, end: 9276 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 9250, end: 9257 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 9259, end: 9266 } + }, + typeArgs: [], + loc: { start: 9259, end: 9266 } + }, + loc: { start: 9250, end: 9266 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'STSLICER' ] + }, + loc: { start: 9206, end: 9289 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 9241, end: 9248 } + }, + loc: { start: 9241, end: 9248 } + } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9482, end: 9498 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'hash', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9514, end: 9515 } + }, + typeArgs: [ + { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + } + ], + loc: { start: 9514, end: 9515 } + }, + initializer: undefined, + loc: { start: 9505, end: 9515 } + } + ], + loc: { start: 9475, end: 9518 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emptyBasechainAddress', + loc: { start: 9897, end: 9918 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9922, end: 9938 } + }, + typeArgs: [], + loc: { start: 9922, end: 9938 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 9952, end: 9968 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 9971, end: 9975 } + }, + initializer: { + kind: 'null', + loc: { start: 9977, end: 9981 } + }, + loc: { start: 9971, end: 9981 } + } + ], + loc: { start: 9952, end: 9983 } + }, + loc: { start: 9945, end: 9984 } + } + ] + }, + loc: { start: 9886, end: 9986 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10311, end: 10330 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10343, end: 10359 } + }, + typeArgs: [], + loc: { start: 10343, end: 10359 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10331, end: 10335 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10337, end: 10340 } + }, + loc: { start: 10331, end: 10340 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'struct_instance', + type: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10373, end: 10389 } + }, + typeArgs: [], + args: [ + { + kind: 'struct_field_initializer', + field: { + kind: 'id', + text: 'hash', + loc: { start: 10392, end: 10396 } + }, + initializer: { + kind: 'var', + name: 'hash', + loc: { start: 10392, end: 10396 } + }, + loc: { start: 10392, end: 10396 } + } + ], + loc: { start: 10373, end: 10398 } + }, + loc: { start: 10366, end: 10399 } + } + ] + }, + loc: { start: 10300, end: 10401 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'contractBasechainAddress', + loc: { start: 10865, end: 10889 } + }, + typeParams: [], + returnType: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 10905, end: 10921 } + }, + typeArgs: [], + loc: { start: 10905, end: 10921 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 's', + loc: { start: 10890, end: 10891 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10893, end: 10902 } + }, + typeArgs: [], + loc: { start: 10893, end: 10902 } + }, + loc: { start: 10890, end: 10902 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'hash', + loc: { start: 10932, end: 10936 } + }, + type: undefined, + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'contractHash', + loc: { start: 10939, end: 10951 } + }, + typeArgs: [], + args: [ + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10952, end: 10953 } + }, + field: { + kind: 'id', + text: 'code', + loc: { start: 10954, end: 10958 } + }, + loc: { start: 10952, end: 10958 } + }, + { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 's', + loc: { start: 10960, end: 10961 } + }, + field: { + kind: 'id', + text: 'data', + loc: { start: 10962, end: 10966 } + }, + loc: { start: 10960, end: 10966 } + } + ], + loc: { start: 10939, end: 10967 } + }, + loc: { start: 10928, end: 10968 } + }, + { + kind: 'statement_return', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'newBasechainAddress', + loc: { start: 10980, end: 10999 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'hash', + loc: { start: 11000, end: 11004 } + } + ], + loc: { start: 10980, end: 11005 } + }, + loc: { start: 10973, end: 11006 } + } + ] + }, + loc: { start: 10854, end: 11008 } + }, + { + kind: 'extension', + fun: { + kind: 'method', + mutates: false, + virtual: false, + override: false, + get: undefined, + fun: { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'storeBasechainAddress', + loc: { start: 11633, end: 11654 } + }, + typeParams: [], + returnType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11698, end: 11705 } + }, + loc: { start: 11698, end: 11705 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 11670, end: 11677 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'BasechainAddress', + loc: { start: 11679, end: 11695 } + }, + typeArgs: [], + loc: { start: 11679, end: 11695 } + }, + loc: { start: 11670, end: 11695 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_condition', + condition: { + kind: 'op_binary', + op: '==', + left: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11716, end: 11723 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11724, end: 11728 } + }, + loc: { start: 11716, end: 11728 } + }, + right: { + kind: 'null', + loc: { start: 11732, end: 11736 } + }, + loc: { start: 11716, end: 11736 } + }, + trueStatements: [ + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11755, end: 11759 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11760, end: 11769 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 11770, end: 11771 } + }, + { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 11773, end: 11774 } + } + ], + loc: { start: 11755, end: 11775 } + }, + loc: { start: 11748, end: 11776 } + } + ], + falseStatements: undefined, + loc: { start: 11712, end: 11790 } + }, + { + kind: 'statement_return', + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'var', + name: 'self', + loc: { start: 11803, end: 11807 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11817, end: 11826 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '2', + value: 1024n, + loc: { start: 11827, end: 11842 } + }, + { + kind: 'op_binary', + op: '+', + left: { + kind: 'number', + base: '10', + value: 3n, + loc: { start: 11844, end: 11845 } + }, + right: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 11848, end: 11849 } + }, + loc: { start: 11844, end: 11849 } + } + ], + loc: { start: 11803, end: 11850 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 11860, end: 11869 } + }, + typeArgs: [], + args: [ + { + kind: 'op_unary', + op: '!!', + operand: { + kind: 'field_access', + aggregate: { + kind: 'var', + name: 'address', + loc: { start: 11870, end: 11877 } + }, + field: { + kind: 'id', + text: 'hash', + loc: { start: 11878, end: 11882 } + }, + loc: { start: 11870, end: 11882 } + }, + loc: { start: 11870, end: 11884 } + }, + { + kind: 'number', + base: '10', + value: 256n, + loc: { start: 11886, end: 11889 } + } + ], + loc: { start: 11803, end: 11890 } + }, + loc: { start: 11796, end: 11891 } + } + ] + }, + loc: { start: 11621, end: 11893 } + } + }, + selfType: { + kind: 'TyBuilder', + format: { + kind: 'SFDefault', + loc: { start: 11661, end: 11668 } + }, + loc: { start: 11661, end: 11668 } + } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceBasechain', + loc: { start: 12980, end: 12994 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 12995, end: 13002 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 13004, end: 13011 } + }, + typeArgs: [], + loc: { start: 13004, end: 13011 } + }, + loc: { start: 12995, end: 13011 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'REWRITESTDADDR DROP 138 THROWIF' ] + }, + loc: { start: 12972, end: 13048 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'forceWorkchain', + loc: { start: 14243, end: 14257 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'address', + loc: { start: 14258, end: 14265 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 14267, end: 14274 } + }, + typeArgs: [], + loc: { start: 14267, end: 14274 } + }, + loc: { start: 14258, end: 14274 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'workchain', + loc: { start: 14276, end: 14285 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14287, end: 14290 } + }, + loc: { start: 14276, end: 14290 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'errorCode', + loc: { start: 14292, end: 14301 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14303, end: 14306 } + }, + loc: { start: 14292, end: 14306 } + } + ], + body: { + kind: 'asm_body', + shuffle: { + args: [ + { + kind: 'id', + text: 'errorCode', + loc: { start: 14210, end: 14219 } + }, + { + kind: 'id', + text: 'workchain', + loc: { start: 14220, end: 14229 } + }, + { + kind: 'id', + text: 'address', + loc: { start: 14230, end: 14237 } + } + ], + ret: [] + }, + instructions: [ + 'REWRITESTDADDR\n DROP\n CMP\n THROWANYIF' + ] + }, + loc: { start: 14206, end: 14362 } + } + ] + }, + loc: { start: 366, end: 394 } + }, + { + kind: 'tact', + source: { + kind: 'tact', + path: 'std/internal/time.tact', + code: '/// Global function.\n' + + '///\n' + + '/// Returns the current Unix time.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let timeOffset: Int = now() + 1000; // thousand seconds from now()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#now\n' + + '///\n' + + 'asm fun now(): Int { NOW }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the logical time of the current transaction.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let lt: Int = curLt();\n' + + '/// nativeRandomize(lt); // equivalent to calling nativeRandomizeLt()\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-contextstate#curlt\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomize\n' + + '/// * https://docs.tact-lang.org/ref/core-random#nativerandomizelt\n' + + '///\n' + + 'asm fun curLt(): Int { LTIME }\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Returns the `Int` value of the starting logical time of the current block.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// let time: Int = blockLt();\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#blocklt\n' + + '///\n' + + 'asm fun blockLt(): Int { BLOCKLT }\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'now', + loc: { start: 263, end: 266 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 270, end: 273 } + }, + loc: { start: 270, end: 273 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'NOW' ] + }, + loc: { start: 255, end: 281 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'curLt', + loc: { start: 785, end: 790 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 794, end: 797 } + }, + loc: { start: 794, end: 797 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'LTIME' ] + }, + loc: { start: 777, end: 807 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'blockLt', + loc: { start: 1108, end: 1115 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1119, end: 1122 } + }, + loc: { start: 1119, end: 1122 } + }, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'BLOCKLT' ] + }, + loc: { start: 1100, end: 1134 } + } + ] + }, + loc: { start: 395, end: 420 } + } + ], + items: [] + }, + loc: { start: 0, end: 0 } + } + ], + items: [ + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'f', loc: { start: 4, end: 5 } }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9, end: 12 } + }, + loc: { start: 9, end: 12 } + }, + params: [], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_return', + expression: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 22, end: 23 } + }, + loc: { start: 15, end: 24 } + } + ] + }, + loc: { start: 0, end: 26 } + } + ] + } + }, + constants: Map(25) { + 'TactExitCodeNullReferenceException' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeInvalidSerializationPrefix' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeInvalidIncomingMessage' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeConstraintsError' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeAccessDenied' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeContractStopped' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeInvalidArgument' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeContractCodeNotFound' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeInvalidStandardAddress' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'TactExitCodeNotBasechainAddress' => { + kind: 'tact', + path: 'std/internal/exit-codes.tact', + code: '/// Configurable since Tact 1.6.\n' + + '///\n' + + '/// Thrown when a null reference exception occurs during the compute phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#128\n' + + '///\n' + + 'const TactExitCodeNullReferenceException: Int = 128;\n' + + '\n' + + '/// Thrown when there is a failed deserialization attempt:\n' + + '/// a certain opcode prefix was expected, but a different one was parsed.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#129\n' + + '///\n' + + 'const TactExitCodeInvalidSerializationPrefix: Int = 129;\n' + + '\n' + + '/// Thrown when there is no receiver for the opcode of the received message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#130\n' + + '///\n' + + 'const TactExitCodeInvalidIncomingMessage: Int = 130;\n' + + '\n' + + '/// Constraints error. Reserved, but never thrown.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#131\n' + + '///\n' + + 'const TactExitCodeConstraintsError: Int = 131;\n' + + '\n' + + '/// Thrown when the sender is not the owner of the contract inheriting\n' + + '/// the `Ownable` trait and there has been a mismatch of the `self.owner`\n' + + "/// and the sender's address.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#132\n' + + '///\n' + + 'const TactExitCodeAccessDenied: Int = 132;\n' + + '\n' + + '/// Thrown when a message has been sent to a contract inheriting the `Stoppable`\n' + + '/// trait and has the `self.stopped` flag set to `true`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#133\n' + + '///\n' + + 'const TactExitCodeContractStopped: Int = 133;\n' + + '\n' + + '/// Thrown when an invalid or unexpected argument is passed to a function or method.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#134\n' + + '///\n' + + 'const TactExitCodeInvalidArgument: Int = 134;\n' + + '\n' + + "/// Thrown when a contract's code is missing.\n" + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#135\n' + + '///\n' + + 'const TactExitCodeContractCodeNotFound: Int = 135;\n' + + '\n' + + '/// Thrown when an address does not conform to the expected standard format.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#136\n' + + '///\n' + + 'const TactExitCodeInvalidStandardAddress: Int = 136;\n' + + '\n' + + '/// Available since Tact 1.6.3.\n' + + '///\n' + + '/// Thrown when the address does not belong to a basechain (chain ID 0).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/exit-codes#138\n' + + '///\n' + + 'const TactExitCodeNotBasechainAddress: Int = 138;\n', + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNullReferenceException', + loc: { start: 183, end: 217 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 219, end: 222 } + }, + loc: { start: 219, end: 222 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 225, end: 228 } + } + }, + loc: { start: 177, end: 229 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidSerializationPrefix', + loc: { start: 434, end: 472 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 474, end: 477 } + }, + loc: { start: 474, end: 477 } + }, + initializer: { + kind: 'number', + base: '10', + value: 129n, + loc: { start: 480, end: 483 } + } + }, + loc: { start: 428, end: 484 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidIncomingMessage', + loc: { start: 633, end: 667 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 669, end: 672 } + }, + loc: { start: 669, end: 672 } + }, + initializer: { + kind: 'number', + base: '10', + value: 130n, + loc: { start: 675, end: 678 } + } + }, + loc: { start: 627, end: 679 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeConstraintsError', + loc: { start: 802, end: 830 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 832, end: 835 } + }, + loc: { start: 832, end: 835 } + }, + initializer: { + kind: 'number', + base: '10', + value: 131n, + loc: { start: 838, end: 841 } + } + }, + loc: { start: 796, end: 842 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeAccessDenied', + loc: { start: 1089, end: 1113 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1115, end: 1118 } + }, + loc: { start: 1115, end: 1118 } + }, + initializer: { + kind: 'number', + base: '10', + value: 132n, + loc: { start: 1121, end: 1124 } + } + }, + loc: { start: 1083, end: 1125 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractStopped', + loc: { start: 1335, end: 1362 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1364, end: 1367 } + }, + loc: { start: 1364, end: 1367 } + }, + initializer: { + kind: 'number', + base: '10', + value: 133n, + loc: { start: 1370, end: 1373 } + } + }, + loc: { start: 1329, end: 1374 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidArgument', + loc: { start: 1531, end: 1558 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1560, end: 1563 } + }, + loc: { start: 1560, end: 1563 } + }, + initializer: { + kind: 'number', + base: '10', + value: 134n, + loc: { start: 1566, end: 1569 } + } + }, + loc: { start: 1525, end: 1570 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeContractCodeNotFound', + loc: { start: 1688, end: 1720 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1722, end: 1725 } + }, + loc: { start: 1722, end: 1725 } + }, + initializer: { + kind: 'number', + base: '10', + value: 135n, + loc: { start: 1728, end: 1731 } + } + }, + loc: { start: 1682, end: 1732 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeInvalidStandardAddress', + loc: { start: 1881, end: 1915 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1917, end: 1920 } + }, + loc: { start: 1917, end: 1920 } + }, + initializer: { + kind: 'number', + base: '10', + value: 136n, + loc: { start: 1923, end: 1926 } + } + }, + loc: { start: 1875, end: 1927 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'TactExitCodeNotBasechainAddress', + loc: { start: 2108, end: 2139 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2141, end: 2144 } + }, + loc: { start: 2141, end: 2144 } + }, + initializer: { + kind: 'number', + base: '10', + value: 138n, + loc: { start: 2147, end: 2150 } + } + }, + loc: { start: 2102, end: 2151 } + } + ] + }, + 'ReserveExact' => { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + 'ReserveAllExcept' => { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + 'ReserveAtMost' => { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + 'ReserveAddOriginalBalance' => { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + 'ReserveInvertSign' => { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + 'ReserveBounceIfActionFail' => { + kind: 'tact', + path: 'std/internal/reserve.tact', + code: '/// Executes the native `RAWRESERVE` instruction with the specified amount and mode.\n' + + '/// The `RAWRESERVE` instruction creates an output action to reserve a specific amount of\n' + + '/// [nanoToncoin] from the remaining balance of the account.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction takes two arguments:\n' + + '/// * `amount`: The number of [nanoToncoin] to reserve.\n' + + '/// * `mode`: Determines the reservation behavior.\n' + + '///\n' + + '/// The `RAWRESERVE` instruction is roughly equivalent to creating an outbound message\n' + + '/// carrying the specified `amount` of [nanoToncoin] (or `b - amount` [nanoToncoin],\n' + + '/// where `b` is the remaining balance) to oneself.\n' + + '/// This ensures that subsequent output actions cannot spend more money than the remainder.\n' + + '///\n' + + '/// It is possible to use raw `Int` values and manually provide them for the `mode`,\n' + + "/// but for your convenience, there's a set of constants you may use to construct the\n" + + '/// compound `mode` with ease.\n' + + '///\n' + + '/// NOTE: Currently, `amount` must be a non-negative integer, and `mode` must be in the\n' + + '/// range `0..31`, inclusive.\n' + + '///\n' + + '/// Additionally, attempts to queue more than 255 reservations in one transaction throw an\n' + + '/// exception with [exit code 33]: `Action list is too long`.\n' + + '///\n' + + '/// NOTE: This function is gas-expensive and uses 500 gas units or more.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve\n' + + '///\n' + + '/// [exit code 33]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '/// [nanoToncoin]: https://docs.tact-lang.org/book/integers#nanotoncoin\n' + + 'asm fun nativeReserve(amount: Int, mode: Int) { RAWRESERVE }\n' + + '\n' + + '/// Reserves exactly the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveExact: Int = 0;\n' + + '\n' + + '/// Reserves all but the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAllExcept: Int = 1;\n' + + '\n' + + '/// Reserves at most the specified `amount` of\n' + + '/// [nanoToncoin](https://docs.tact-lang.org/book/integers#nanotoncoin).\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-base-modes\n' + + '///\n' + + 'const ReserveAtMost: Int = 2;\n' + + '\n' + + '/// Increases the `amount` by the original balance of the current account\n' + + '/// (before the compute phase), including all extra currencies.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveAddOriginalBalance: Int = 4;\n' + + '\n' + + '/// Negates the `amount` value before performing the reservation.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveInvertSign: Int = 8;\n' + + '\n' + + '/// Bounces the transaction if the reservation fails.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-contextstate#nativereserve-optional-flags\n' + + '///\n' + + 'const ReserveBounceIfActionFail: Int = 16;\n', + imports: [], + items: [ + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeReserve', + loc: { start: 1509, end: 1522 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'amount', + loc: { start: 1523, end: 1529 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1531, end: 1534 } + }, + loc: { start: 1523, end: 1534 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 1536, end: 1540 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1542, end: 1545 } + }, + loc: { start: 1536, end: 1545 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'RAWRESERVE' ] + }, + loc: { start: 1501, end: 1561 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveExact', + loc: { start: 1780, end: 1792 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1794, end: 1797 } + }, + loc: { start: 1794, end: 1797 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 1800, end: 1801 } + } + }, + loc: { start: 1774, end: 1802 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAllExcept', + loc: { start: 2021, end: 2037 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2039, end: 2042 } + }, + loc: { start: 2039, end: 2042 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 2045, end: 2046 } + } + }, + loc: { start: 2015, end: 2047 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAtMost', + loc: { start: 2266, end: 2279 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2281, end: 2284 } + }, + loc: { start: 2281, end: 2284 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 2287, end: 2288 } + } + }, + loc: { start: 2260, end: 2289 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveAddOriginalBalance', + loc: { start: 2530, end: 2555 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2557, end: 2560 } + }, + loc: { start: 2557, end: 2560 } + }, + initializer: { + kind: 'number', + base: '10', + value: 4n, + loc: { start: 2563, end: 2564 } + } + }, + loc: { start: 2524, end: 2565 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveInvertSign', + loc: { start: 2734, end: 2751 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2753, end: 2756 } + }, + loc: { start: 2753, end: 2756 } + }, + initializer: { + kind: 'number', + base: '10', + value: 8n, + loc: { start: 2759, end: 2760 } + } + }, + loc: { start: 2728, end: 2761 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'ReserveBounceIfActionFail', + loc: { start: 2918, end: 2943 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2945, end: 2948 } + }, + loc: { start: 2945, end: 2948 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 2951, end: 2953 } + } + }, + loc: { start: 2912, end: 2954 } + } + ] + }, + 'SendDefaultMode' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendRemainingValue' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendRemainingBalance' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendOnlyEstimateFee' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendPayGasSeparately' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendPayFwdFeesSeparately' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendIgnoreErrors' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendBounceIfActionFail' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + }, + 'SendDestroyIfZero' => { + kind: 'tact', + path: 'std/internal/send.tact', + code: '/// Ordinary message (default).\n' + + '///\n' + + '/// This constant is available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendDefaultMode: Int = 0;\n' + + '\n' + + '/// Carry all the remaining value of the inbound message in addition\n' + + '/// to the value initially indicated in the new message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingValue: Int = 64;\n' + + '\n' + + '/// Carry **all the remaining balance** of the current smart contract instead\n' + + '/// of the value originally indicated in the message.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '///\n' + + 'const SendRemainingBalance: Int = 128;\n' + + '\n' + + "/// Doesn't send the message, only estimates the forward fees\n" + + '/// if the message-sending function computes those.\n' + + '///\n' + + '/// This constant is available since Tact 1.5.0.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/book/message-mode#base-modes\n' + + '/// * https://docs.tact-lang.org/book/send#message-sending-functions\n' + + '///\n' + + 'const SendOnlyEstimateFee: Int = 1024;\n' + + '\n' + + '/// **Deprecated** since Tact 1.6.5.\n' + + '///\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayGasSeparately: Int = 1;\n' + + '\n' + + '/// Pay forward fees separately from the message value.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendPayFwdFeesSeparately: Int = 1;\n' + + '\n' + + '/// Ignore any errors arising while processing this message during the action phase.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendIgnoreErrors: Int = 2;\n' + + '\n' + + '/// Bounce transaction in case of any errors during action phase.\n' + + '/// Has no effect if flag +2, `SendIgnoreErrors` is used.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendBounceIfActionFail: Int = 16;\n' + + '\n' + + '/// Current account (contract) will be destroyed if its resulting balance is zero.\n' + + '/// This flag is often used with mode 128, `SendRemainingBalance`.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/book/message-mode#optional-flags\n' + + '///\n' + + 'const SendDestroyIfZero: Int = 32;\n' + + '\n' + + '/// Struct for specifying the message parameters of the `send()` function.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + 'struct SendParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// Optional initial code of the contract (compiled bitcode).\n' + + ' code: Cell? = null;\n' + + '\n' + + ' /// Optional initial data of the contract (arguments of `init()` function or values of contract parameters).\n' + + ' data: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Struct for specifying the message parameters of the `message()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#message\n' + + '///\n' + + 'struct MessageParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// Recipient internal `Address` on TON Blockchain.\n' + + ' to: Address;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '}\n' + + '\n' + + '/// Global function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// Queues the message to be sent using the `MessageParameters` struct. Allows for cheaper non-deployment, regular messages compared to the `send()` function.\n' + + '///\n' + + '/// The `MessageParameters` struct is similar to `SendParameters` struct, but without the `code` and `data` fields.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// message(MessageParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See:\n' + + '/// * https://docs.tact-lang.org/ref/core-send#message\n' + + '/// * https://docs.tact-lang.org/book/message-mode\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun message(params: MessageParameters) {\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG\n' + + '}\n' + + '\n' + + '/// Global function. Queues the message to be sent using a `SendParameters` Struct.\n' + + '///\n' + + '/// ```tact\n' + + '/// fun example() {\n' + + '/// send(SendParameters{\n' + + '/// to: sender(), // back to the sender,\n' + + '/// value: ton("1"), // with 1 Toncoin (1_000_000_000 nanoToncoin),\n' + + '/// // and no message body\n' + + '/// });\n' + + '/// }\n' + + '/// ```\n' + + '///\n' + + '/// #### Exit codes\n' + + '///\n' + + '/// * 33: [Action list is too long] — Thrown when attempting to queue more than 255 messages.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#send\n' + + '///\n' + + '/// [Action list is too long]: https://docs.tact-lang.org/book/exit-codes#33\n' + + '///\n' + + 'asm fun send(params: SendParameters) {\n' + + ' // Instructions are grouped, and the stack states they produce as a group are shown right after.\n' + + ' // In the end, our message Cell should have the following TL-B structure:\n' + + ' // message$_ {X:Type}\n' + + ' // info:CommonMsgInfoRelaxed\n' + + ' // init:(Maybe (Either StateInit ^StateInit))\n' + + ' // body:(Either X ^X)\n' + + ' // = MessageRelaxed X;\n' + + '\n' + + ' // → Stack state\n' + + ' // s0: `params.bounce`\n' + + ' // s1: `params.to`\n' + + ' // s2: `params.value`\n' + + ' // s3: `params.data`\n' + + ' // s4: `params.code`\n' + + ' // s5: `params.body`\n' + + ' // s6: `params.mode`\n' + + ' // For brevity, the "params" prefix will be omitted from now on.\n' + + '\n' + + ' // Group 1: Storing the `bounce`, `to` and `value` into a Builder\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558\n' + + '}\n' + + '\n' + + '/// Struct for specifying the deployment message parameters of the `deploy()` function. Available since Tact 1.6.0.\n' + + '///\n' + + '/// See: https://docs.tact-lang.org/ref/core-send#deploy\n' + + '///\n' + + 'struct DeployParameters {\n' + + ' /// An 8-bit value that configures how to send a message, defaults to 0.\n' + + ' /// See: https://docs.tact-lang.org/book/message-mode\n' + + ' mode: Int = SendDefaultMode;\n' + + '\n' + + ' /// Optional message body as a `Cell`.\n' + + ' body: Cell? = null;\n' + + '\n' + + ' /// The amount of nanoToncoins you want to send with\n' + + ' /// the message. This value is used to cover forward fees,\n' + + ' /// unless the optional flag `SendPayFwdFeesSeparately` is used.\n' + + ' value: Int;\n' + + '\n' + + ' /// When set to `true` (default) message bounces back to the sender if\n' + + " /// the recipient contract doesn't exist or wasn't able to process the message.\n" + + ' bounce: Bool = true;\n' + + '\n' + + ' //'... 12658 more characters, + imports: [], + items: [ + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDefaultMode', + loc: { start: 164, end: 179 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 181, end: 184 } + }, + loc: { start: 181, end: 184 } + }, + initializer: { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 187, end: 188 } + } + }, + loc: { start: 158, end: 189 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingValue', + loc: { start: 396, end: 414 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 416, end: 419 } + }, + loc: { start: 416, end: 419 } + }, + initializer: { + kind: 'number', + base: '10', + value: 64n, + loc: { start: 422, end: 424 } + } + }, + loc: { start: 390, end: 425 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendRemainingBalance', + loc: { start: 638, end: 658 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 660, end: 663 } + }, + loc: { start: 660, end: 663 } + }, + initializer: { + kind: 'number', + base: '10', + value: 128n, + loc: { start: 666, end: 669 } + } + }, + loc: { start: 632, end: 670 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendOnlyEstimateFee', + loc: { start: 993, end: 1012 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1014, end: 1017 } + }, + loc: { start: 1014, end: 1017 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1024n, + loc: { start: 1020, end: 1024 } + } + }, + loc: { start: 987, end: 1025 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayGasSeparately', + loc: { start: 1207, end: 1227 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1229, end: 1232 } + }, + loc: { start: 1229, end: 1232 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1235, end: 1236 } + } + }, + loc: { start: 1201, end: 1237 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendPayFwdFeesSeparately', + loc: { start: 1378, end: 1402 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1404, end: 1407 } + }, + loc: { start: 1404, end: 1407 } + }, + initializer: { + kind: 'number', + base: '10', + value: 1n, + loc: { start: 1410, end: 1411 } + } + }, + loc: { start: 1372, end: 1412 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendIgnoreErrors', + loc: { start: 1582, end: 1598 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1600, end: 1603 } + }, + loc: { start: 1600, end: 1603 } + }, + initializer: { + kind: 'number', + base: '10', + value: 2n, + loc: { start: 1606, end: 1607 } + } + }, + loc: { start: 1576, end: 1608 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendBounceIfActionFail', + loc: { start: 1817, end: 1839 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 1841, end: 1844 } + }, + loc: { start: 1841, end: 1844 } + }, + initializer: { + kind: 'number', + base: '10', + value: 16n, + loc: { start: 1847, end: 1849 } + } + }, + loc: { start: 1811, end: 1850 } + }, + { + kind: 'constant', + name: { + kind: 'id', + text: 'SendDestroyIfZero', + loc: { start: 2085, end: 2102 } + }, + init: { + kind: 'constant_def', + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2104, end: 2107 } + }, + loc: { start: 2104, end: 2107 } + }, + initializer: { + kind: 'number', + base: '10', + value: 32n, + loc: { start: 2110, end: 2112 } + } + }, + loc: { start: 2079, end: 2113 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 2260, end: 2274 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 2416, end: 2420 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2422, end: 2425 } + }, + loc: { start: 2422, end: 2425 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 2428, end: 2443 } + }, + loc: { start: 2416, end: 2443 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 2493, end: 2497 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2503, end: 2504 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2499, end: 2503 } + }, + loc: { start: 2499, end: 2503 } + } + ], + loc: { start: 2503, end: 2504 } + }, + initializer: { kind: 'null', loc: { start: 2507, end: 2511 } }, + loc: { start: 2493, end: 2511 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'code', + loc: { start: 2584, end: 2588 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2594, end: 2595 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2590, end: 2594 } + }, + loc: { start: 2590, end: 2594 } + } + ], + loc: { start: 2594, end: 2595 } + }, + initializer: { kind: 'null', loc: { start: 2598, end: 2602 } }, + loc: { start: 2584, end: 2602 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'data', + loc: { start: 2722, end: 2726 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 2732, end: 2733 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 2728, end: 2732 } + }, + loc: { start: 2728, end: 2732 } + } + ], + loc: { start: 2732, end: 2733 } + }, + initializer: { kind: 'null', loc: { start: 2736, end: 2740 } }, + loc: { start: 2722, end: 2740 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 2936, end: 2941 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 2943, end: 2946 } + }, + loc: { start: 2943, end: 2946 } + }, + initializer: undefined, + loc: { start: 2936, end: 2946 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3009, end: 3011 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3013, end: 3020 } + }, + typeArgs: [], + loc: { start: 3013, end: 3020 } + }, + initializer: undefined, + loc: { start: 3009, end: 3020 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 3186, end: 3192 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 3194, end: 3198 } + }, + typeArgs: [], + loc: { start: 3194, end: 3198 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 3201, end: 3205 } + }, + loc: { start: 3186, end: 3205 } + } + ], + loc: { start: 2253, end: 3208 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 3389, end: 3406 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 3548, end: 3552 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3554, end: 3557 } + }, + loc: { start: 3554, end: 3557 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 3560, end: 3575 } + }, + loc: { start: 3548, end: 3575 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 3625, end: 3629 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 3635, end: 3636 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 3631, end: 3635 } + }, + loc: { start: 3631, end: 3635 } + } + ], + loc: { start: 3635, end: 3636 } + }, + initializer: { kind: 'null', loc: { start: 3639, end: 3643 } }, + loc: { start: 3625, end: 3643 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 3839, end: 3844 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 3846, end: 3849 } + }, + loc: { start: 3846, end: 3849 } + }, + initializer: undefined, + loc: { start: 3839, end: 3849 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'to', + loc: { start: 3912, end: 3914 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 3916, end: 3923 } + }, + typeArgs: [], + loc: { start: 3916, end: 3923 } + }, + initializer: undefined, + loc: { start: 3912, end: 3923 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 4089, end: 4095 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 4097, end: 4101 } + }, + typeArgs: [], + loc: { start: 4097, end: 4101 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 4104, end: 4108 } + }, + loc: { start: 4089, end: 4108 } + } + ], + loc: { start: 3382, end: 4111 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'message', + loc: { start: 5056, end: 5063 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 5064, end: 5070 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'MessageParameters', + loc: { start: 5072, end: 5089 } + }, + typeArgs: [], + loc: { start: 5072, end: 5089 } + }, + loc: { start: 5064, end: 5089 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 106 PUSHINT // 1 + 4 + 4 + 64 + 32 + 1\n' + + ' STZEROES\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + ' STDICT\n' + + ' ENDC\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 5048, end: 5588 } + }, + { + kind: 'function', + inline: false, + name: { kind: 'id', text: 'send', loc: { start: 6219, end: 6223 } }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 6224, end: 6230 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'SendParameters', + loc: { start: 6232, end: 6246 } + }, + typeArgs: [], + loc: { start: 6232, end: 6246 } + }, + loc: { start: 6224, end: 6246 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + 'NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' b{000} STSLICECONST // store bounced = false and src = addr_none\n' + + ' STSLICE // store `to`\n' + + ' SWAP\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: `data`\n' + + ' // s2: `code`\n' + + ' // s3: `body`\n' + + ' // s4: `mode`\n' + + '\n' + + ' // Group 2: Placing the Builder after code and data, then checking those for nullability\n' + + ' s2 XCHG0\n' + + ' DUP2\n' + + ' ISNULL\n' + + ' SWAP\n' + + ' ISNULL\n' + + ' AND\n' + + ' // → Stack state\n' + + ' // s0: -1 (true) if `data` and `code` are both null, 0 (false) otherwise\n' + + ' // s1: `code`\n' + + ' // s2: `data`\n' + + ' // s3: Builder\n' + + ' // s4: `body`\n' + + ' // s5: `mode`\n' + + '\n' + + ' // Group 3: Left branch of the IFELSE, executed if s0 is -1 (true)\n' + + ' <{\n' + + ' DROP2 // drop `data` and `code`, since either of those is null\n' + + ' b{0} STSLICECONST\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: Right branch of the IFELSE, executed if s0 is 0 (false)\n' + + ' <{\n' + + ' // _ split_depth:(Maybe (## 5))\n' + + ' // special:(Maybe TickTock)\n' + + ' // code:(Maybe ^Cell)\n' + + ' // data:(Maybe ^Cell)\n' + + ' // library:(Maybe ^Cell)\n' + + ' // = StateInit;\n' + + ' ROT // place message Builder on top\n' + + ' b{10} STSLICECONST // store Maybe = true, Either = false\n' + + ' // Start composing inlined StateInit\n' + + ' b{00} STSLICECONST // store split_depth and special first\n' + + ' STDICT // store code\n' + + ' STDICT // store data\n' + + ' b{0} STSLICECONST // store library\n' + + ' }> PUSHCONT\n' + + '\n' + + ' // Group 3: IFELSE that does the branching shown above\n' + + ' IFELSE\n' + + ' // → Stack state\n' + + ' // s0: Builder\n' + + ' // s1: null or StateInit\n' + + ' // s2: `body`\n' + + ' // s3: `mode`\n' + + '\n' + + ' // Group 4: Finalizing the message\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: `mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG // https://github.com/tact-lang/tact/issues/1558' + ] + }, + loc: { start: 6211, end: 9157 } + }, + { + kind: 'struct_decl', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 9347, end: 9363 } + }, + typeParams: [], + fields: [ + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'mode', + loc: { start: 9505, end: 9509 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9511, end: 9514 } + }, + loc: { start: 9511, end: 9514 } + }, + initializer: { + kind: 'var', + name: 'SendDefaultMode', + loc: { start: 9517, end: 9532 } + }, + loc: { start: 9505, end: 9532 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'body', + loc: { start: 9582, end: 9586 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Maybe', + loc: { start: 9592, end: 9593 } + }, + typeArgs: [ + { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 9588, end: 9592 } + }, + loc: { start: 9588, end: 9592 } + } + ], + loc: { start: 9592, end: 9593 } + }, + initializer: { kind: 'null', loc: { start: 9596, end: 9600 } }, + loc: { start: 9582, end: 9600 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'value', + loc: { start: 9796, end: 9801 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 9803, end: 9806 } + }, + loc: { start: 9803, end: 9806 } + }, + initializer: undefined, + loc: { start: 9796, end: 9806 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'bounce', + loc: { start: 9972, end: 9978 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Bool', + loc: { start: 9980, end: 9984 } + }, + typeArgs: [], + loc: { start: 9980, end: 9984 } + }, + initializer: { + kind: 'boolean', + value: true, + loc: { start: 9987, end: 9991 } + }, + loc: { start: 9972, end: 9991 } + }, + { + kind: 'field_decl', + name: { + kind: 'id', + text: 'init', + loc: { start: 10135, end: 10139 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'StateInit', + loc: { start: 10141, end: 10150 } + }, + typeArgs: [], + loc: { start: 10141, end: 10150 } + }, + initializer: undefined, + loc: { start: 10135, end: 10150 } + } + ], + loc: { start: 9340, end: 10153 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'deploy', + loc: { start: 11796, end: 11802 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'params', + loc: { start: 11803, end: 11809 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'DeployParameters', + loc: { start: 11811, end: 11827 } + }, + typeArgs: [], + loc: { start: 11811, end: 11827 } + }, + loc: { start: 11803, end: 11827 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '4 1 BLKPUSH // pushes 2 copies of `init.code` and `init.data`\n' + + ' HASHCU // `init.data` hash\n' + + ' SWAP\n' + + ' HASHCU // `init.code` hash\n' + + ' SWAP2\n' + + ' CDEPTH // `init.data` depth\n' + + ' SWAP\n' + + ' CDEPTH // `init.code` depth\n' + + '\n' + + ' // Group 2: Calculating destination address\n' + + ' // For almost identical logic and instructions,\n' + + ' // see comments inside `contractHash()` function in contract.tact\n' + + ' 131380 INT // (2 << 16) | (1 << 8) | 0x34\n' + + ' NEWC\n' + + ' 24 STU\n' + + ' 16 STU\n' + + ' 16 STU\n' + + ' 256 STU\n' + + ' 256 STU\n' + + ' ONE HASHEXT_SHA256 // obtains hash part (account id) of the address\n' + + ' // → Stack state\n' + + ' // s0: destAddr(hash part)\n' + + ' // s1: `init.data`\n' + + ' // s2: `init.code`\n' + + ' // s3 and below: `bounce`, `value`, `body`, `mode`\n' + + '\n' + + ' // Group 3: Building a message (CommonMsgInfoRelaxed)\n' + + ' s3 XCHG0 // swaps `bounce` with destAddr(hash part)\n' + + ' NEWC\n' + + ' b{01} STSLICECONST // store tag = $0 and ihr_disabled = true\n' + + ' 1 STI // store `bounce`\n' + + ' s1 s2 XCHG // swap `init.data` with `init.code`, placing code on s1\n' + + ' STREF // store `init.code`\n' + + ' STREF // store `init.data`\n' + + ' // Inline StateInit:\n' + + ' b{00010000000000} STSLICECONST\n' + + ' // 0 + 00 + 10 + 0 + 00000000\n' + + ' // 1) 0 - bounced = false\n' + + ' // 2) 00 - src = addr_none\n' + + ' // 3) 10 - tag of addr_std (part of dest)\n' + + ' // 4) 0 - Maybe Anycast = false\n' + + ' // 5) 00000000 - workchain_id (part of dest)\n' + + ' //\n' + + ' 256 STU // store destAddr(hash part)\n' + + ' SWAP // Builder on top, `value` below\n' + + ' STGRAMS // store `value`\n' + + ' 105 PUSHINT // 1 + 4 + 4 + 64 + 32\n' + + ' STZEROES // store currency_collection, ihr_fee, fwd_fee, created_lt and created_at\n' + + '\n' + + ' // Group 4: Continue building a message (CommonMsgInfoRelaxed into MessageRelaxed)\n' + + ' // Remaining bits of MessageRelaxed:\n' + + ' b{1000110} STSLICECONST\n' + + ' // 10 + 0 + 0 + 1 + 1 + 0\n' + + ' // 10 - Maybe (Either StateInit ^StateInit) = true false\n' + + ' // 0 - split_depth:(Maybe (## 5)) = false\n' + + ' // 0 = special:(Maybe TickTock) = false\n' + + ' // 1 = code:(Maybe ^Cell) = true\n' + + ' // 1 = data:(Maybe ^Cell) = true\n' + + ' // 0 = library:(Maybe ^Cell) = false\n' + + ' //\n' + + ' STDICT // store `body` as ref with an extra Maybe bit, since `body` might be null\n' + + ' ENDC // finalize the message\n' + + ' // → Stack state\n' + + ' // s0: Cell\n' + + ' // s1: params.`mode`\n' + + '\n' + + ' // Group 5: Sending the message, with `mode` on top\n' + + ' SWAP\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 11788, end: 14770 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'cashback', + loc: { start: 15971, end: 15979 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'to', + loc: { start: 15980, end: 15982 } + }, + type: { + kind: 'cons_type', + name: { + kind: 'type_id', + text: 'Address', + loc: { start: 15984, end: 15991 } + }, + typeArgs: [], + loc: { start: 15984, end: 15991 } + }, + loc: { start: 15980, end: 15991 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ + '16 PUSHINT // 0x10, i.e. 0x18 but with bounce = false\n' + + ' NEWC\n' + + ' 6 STU // .storeUint(0x10, 6)\n' + + ' STSLICE // .storeAddress(to)\n' + + ' 0 PUSHINT // 0\n' + + ' 111 STUR // .storeUint(0, 111)\n' + + ' // 4 zeros for coins and 107 zeros for lt, fees, etc.\n' + + ' ENDC\n' + + ' 66 PUSHINT // SendRemainingValue | SendIgnoreErrors\n' + + ' SENDRAWMSG' + ] + }, + loc: { start: 15963, end: 16385 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessage', + loc: { start: 16936, end: 16953 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 16954, end: 16957 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16959, end: 16963 } + }, + loc: { start: 16954, end: 16963 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 16965, end: 16969 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16971, end: 16974 } + }, + loc: { start: 16965, end: 16974 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 16928, end: 16990 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 17751, end: 17765 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 17766, end: 17769 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17771, end: 17775 } + }, + loc: { start: 17766, end: 17775 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 17777, end: 17781 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17783, end: 17786 } + }, + loc: { start: 17777, end: 17786 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDRAWMSG' ] + }, + loc: { start: 17743, end: 17802 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'nativeSendMessageReturnForwardFee', + loc: { start: 19063, end: 19096 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19120, end: 19123 } + }, + loc: { start: 19120, end: 19123 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 19097, end: 19100 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19102, end: 19106 } + }, + loc: { start: 19097, end: 19106 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 19108, end: 19112 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19114, end: 19117 } + }, + loc: { start: 19108, end: 19117 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 19055, end: 19135 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'sendMessageReturnForwardFee', + loc: { start: 20186, end: 20213 } + }, + typeParams: [], + returnType: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20237, end: 20240 } + }, + loc: { start: 20237, end: 20240 } + }, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'msg', + loc: { start: 20214, end: 20217 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20219, end: 20223 } + }, + loc: { start: 20214, end: 20223 } + }, + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'mode', + loc: { start: 20225, end: 20229 } + }, + type: { + kind: 'TyInt', + format: { + kind: 'FInt', + sign: 'signed', + width: 257, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20231, end: 20234 } + }, + loc: { start: 20225, end: 20234 } + } + ], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'SENDMSG' ] + }, + loc: { start: 20178, end: 20252 } + }, + { + kind: 'function', + inline: true, + name: { + kind: 'id', + text: 'emit', + loc: { start: 21033, end: 21037 } + }, + typeParams: [], + returnType: undefined, + params: [ + { + kind: 'typed_parameter', + name: { + kind: 'id', + text: 'body', + loc: { start: 21038, end: 21042 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21044, end: 21048 } + }, + loc: { start: 21038, end: 21048 } + } + ], + body: { + kind: 'regular_body', + statements: [ + { + kind: 'statement_let', + name: { + kind: 'id', + text: 'c', + loc: { start: 21233, end: 21234 } + }, + type: { + kind: 'TyCell', + format: { + kind: 'SFDefault', + loc: { start: 21236, end: 21240 } + }, + loc: { start: 21236, end: 21240 } + }, + expression: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'method_call', + self: { + kind: 'static_call', + function: { + kind: 'id', + text: 'beginCell', + loc: { start: 21243, end: 21252 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21254 } + }, + method: { + kind: 'id', + text: 'storeUint', + loc: { start: 21264, end: 21273 } + }, + typeArgs: [], + args: [ + { + kind: 'number', + base: '10', + value: 15211807202738752817960438464513n, + loc: { start: 21274, end: 21306 } + }, + { + kind: 'number', + base: '10', + value: 104n, + loc: { start: 21308, end: 21311 } + } + ], + loc: { start: 21243, end: 21312 } + }, + method: { + kind: 'id', + text: 'storeRef', + loc: { start: 21322, end: 21330 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'body', + loc: { start: 21331, end: 21335 } + } + ], + loc: { start: 21243, end: 21336 } + }, + method: { + kind: 'id', + text: 'endCell', + loc: { start: 21346, end: 21353 } + }, + typeArgs: [], + args: [], + loc: { start: 21243, end: 21355 } + }, + loc: { start: 21229, end: 21356 } + }, + { + kind: 'statement_expression', + expression: { + kind: 'static_call', + function: { + kind: 'id', + text: 'sendRawMessage', + loc: { start: 21361, end: 21375 } + }, + typeArgs: [], + args: [ + { + kind: 'var', + name: 'c', + loc: { start: 21376, end: 21377 } + }, + { + kind: 'number', + base: '10', + value: 0n, + loc: { start: 21379, end: 21380 } + } + ], + loc: { start: 21361, end: 21381 } + }, + loc: { start: 21361, end: 21382 } + } + ] + }, + loc: { start: 21022, end: 21384 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'acceptMessage', + loc: { start: 22124, end: 22137 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'ACCEPT' ] + }, + loc: { start: 22116, end: 22150 } + }, + { + kind: 'function', + inline: false, + name: { + kind: 'id', + text: 'commit', + loc: { start: 22638, end: 22644 } + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: 'asm_body', + shuffle: { args: [], ret: [] }, + instructions: [ 'COMMIT' ] + }, + loc: { start: 22630, end: 22657 } + } + ] + } + } +} diff --git a/spell/cspell-list.txt b/spell/cspell-list.txt index 11b6b8b52d..59f431d75f 100644 --- a/spell/cspell-list.txt +++ b/spell/cspell-list.txt @@ -33,6 +33,8 @@ Comptime CSBT Daniil Danil +dealias +dealiased decompilation Decompilation decompile @@ -55,10 +57,12 @@ errno Esorat Excno extracurrency +Fieldish flamegraph flamegraphs forall formedness +froms frontmatter funcfiftlib funcid @@ -77,6 +81,7 @@ Hoppity idict Ikko Ilya +implicits infixl infixr initof @@ -127,12 +132,14 @@ miscompilation misparse misparsed mktemp +Monoid multiformats nanoton nanotons Nemo Neovim nextra +nexts nobounce nocheck noexcept @@ -151,6 +158,7 @@ pinst POSIX postpack prando +prevs quadtree quadtrees RANDU @@ -174,6 +182,7 @@ seti shardchains shiki Shvetc +Signedness skywardboundd Stateinit statinit @@ -207,6 +216,7 @@ Topup Tradoor Trunov typechecker +typedecl udict uintptr uints diff --git a/src/cli/colors.ts b/src/cli/colors.ts index 1d4d934cf2..77d15f2cba 100644 --- a/src/cli/colors.ts +++ b/src/cli/colors.ts @@ -4,8 +4,8 @@ export const isColorSupported = () => { if (process.platform === "win32") { const [major, _, build] = release().split(".").map(Number); // Windows 10, Build 10586+ - return ( - (major && major > 10) || (major === 10 && build && build >= 10586) + return Boolean( + (major && major > 10) || (major === 10 && build && build >= 10586), ); } if (process.stdout.isTTY && process.env.TERM !== "dumb") { diff --git a/src/error/logger-util.ts b/src/error/logger-util.ts index ee2f0b5771..8a403e1c5a 100644 --- a/src/error/logger-util.ts +++ b/src/error/logger-util.ts @@ -92,10 +92,15 @@ const mapBaseLogger = ( }, }); +/** + * `SourceLogger` or top-level `Logger` + */ +export interface AnyLogger extends Formatter, BaseLogger {} + /** * Logger that knows about currently compiled file */ -export interface SourceLogger extends Formatter, BaseLogger { +export interface SourceLogger extends AnyLogger { /** * Choose range where an error will be shown */ @@ -110,7 +115,7 @@ export interface SourceLogger extends Formatter, BaseLogger { /** * Top-level logger */ -export interface Logger extends Formatter, BaseLogger { +export interface Logger extends AnyLogger { /** * Set currently compiled source in logging context */ diff --git a/src/imports/path.ts b/src/imports/path.ts index 5a45ee0817..4acc8accf5 100644 --- a/src/imports/path.ts +++ b/src/imports/path.ts @@ -1,9 +1,6 @@ import { throwInternalCompilerError } from "@/error/errors"; import { repeat } from "@/utils/array"; -// Witness tag. Do not use, do not export. -const pathTag = Symbol("path"); - /** * Safe relative path */ @@ -16,10 +13,6 @@ export type RelativePath = { * /-separated strings that go after optional ../ */ readonly segments: readonly string[]; - /** - * Proof that path was created by RelativePath constructor - */ - readonly [pathTag]: true; }; /** @@ -33,7 +26,6 @@ const RelativePath = ( throwInternalCompilerError("Negative number of ../ in path"); } const result: RelativePath = { - [pathTag]: true, stepsUp, segments: Object.freeze(segments), }; diff --git a/src/next/ast/allocation.ts b/src/next/ast/allocation.ts new file mode 100644 index 0000000000..acd2b857ad --- /dev/null +++ b/src/next/ast/allocation.ts @@ -0,0 +1,121 @@ +import type * as Ast from "@/next/ast"; +// import * as E from "@/next/types/errors"; + +export type TlbType = + | TlbInt + | TlbVarInt + | TlbBool + | TlbAddress + | TlbString + | TlbUnknown + | TlbLiteral + | TlbBits + | TlbMap + | TlbRef + | TlbMaybe + | TlbFields + | TlbUnion; + +export type TlbTypeNoRef = + | TlbInt + | TlbVarInt + | TlbBool + | TlbAddress + | TlbLiteral + | TlbBits + | TlbMaybeNoRef + | TlbFieldsNoRef + | TlbUnionNoRef; + +export type TlbInt = { + readonly kind: "int"; + readonly sign: Ast.Signedness; + readonly width: number; +}; + +export type TlbVarInt = { + readonly kind: "varint"; + readonly sign: Ast.Signedness; + readonly width: Ast.VarIntWidth; +}; + +export type TlbBool = { + readonly kind: "bool"; +}; + +export type TlbAddress = { + readonly kind: "address"; +}; + +export type TlbString = { + readonly kind: "string"; +}; + +export type TlbUnknown = { + // aka ^Cell + readonly kind: "unknown"; +}; + +export type TlbLiteral = { + readonly kind: "literal"; + readonly width: number; + readonly value: bigint; +}; + +export type TlbBits = { + readonly kind: "ref"; + readonly width: number; +}; + +export type TlbRef = { + readonly kind: "ref"; + readonly type: TlbType; +}; + +export type TlbMap = { + readonly kind: "map"; + readonly key: TlbTypeNoRef; + readonly value: TlbType; +}; + +export type TlbMaybe = { + readonly kind: "maybe"; + readonly type: TlbType; +}; + +export type TlbFields = { + readonly kind: "fields"; + readonly children: readonly TlbType[]; +}; + +export type TlbUnion = { + readonly kind: "union"; + readonly prefixWidth: number; + readonly children: readonly TlbCase[]; +}; + +export type TlbCase = { + readonly prefix: bigint; + readonly type: TlbType; +}; + +export type TlbMaybeNoRef = { + readonly kind: "maybe"; + readonly type: TlbCaseNoRef; +}; + +export type TlbFieldsNoRef = { + readonly kind: "fields"; + readonly children: readonly TlbCaseNoRef[]; +}; + +export type TlbUnionNoRef = { + readonly kind: "union"; + readonly prefixWidth: number; + readonly children: readonly TlbCaseNoRef[]; +}; + +export type TlbCaseNoRef = { + readonly prefix: bigint; + readonly type: TlbCaseNoRef; +}; diff --git a/src/next/ast/checked-expr.ts b/src/next/ast/checked-expr.ts new file mode 100644 index 0000000000..5ded45bd87 --- /dev/null +++ b/src/next/ast/checked-expr.ts @@ -0,0 +1,227 @@ +import type { Recover } from "@/next/ast/checked"; +import type { Id, Loc, Ordered, TypeId } from "@/next/ast/common"; +import type * as D from "@/next/ast/checked-type"; +import type { + BinaryOperation, + NumberBase, + UnaryOperation, +} from "@/next/ast/expression"; +import type { SelfType } from "@/next/ast/type-self"; + +export type TypeArgs = ReadonlyMap; + +export type CExpr = + | COpBinary + | COpUnary + | CConditional + | CMethodCall + | CStaticCall + | CStaticMethodCall + | CFieldAccess + | CStructCons + | CInitOf + | CCodeOf + | CNumber + | CBoolean + | CNull + | CString + | CVar + | CSelf + | CUnit + | CTuple + | CTensor + | CMapLiteral + | CSetLiteral; + +export type CLValue = CLVar | CLSelf | CLFieldAccess; + +export type CLSelf = { + readonly kind: "self"; + readonly computedType: SelfType; + readonly loc: Loc; +}; + +export type CLVar = { + readonly kind: "var"; + readonly name: string; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CLFieldAccess = { + readonly kind: "field_access"; + readonly aggregate: CLValue; + readonly field: Id; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CSelf = { + readonly kind: "self"; + readonly computedType: SelfType; + readonly loc: Loc; +}; + +export type CVar = { + readonly kind: "var"; + readonly name: string; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CNumber = { + readonly kind: "number"; + readonly base: NumberBase; + readonly value: bigint; + readonly computedType: D.CTBasic; + readonly loc: Loc; +}; + +export type CBoolean = { + readonly kind: "boolean"; + readonly value: boolean; + readonly computedType: D.CTBasic; + readonly loc: Loc; +}; + +export type CString = { + readonly kind: "string"; + readonly value: string; + readonly computedType: D.CTBasic; + readonly loc: Loc; +}; + +export type CNull = { + readonly kind: "null"; + readonly computedType: D.CTBasic; + readonly loc: Loc; +}; + +export type COpBinary = { + readonly kind: "op_binary"; + readonly op: BinaryOperation; + readonly left: CExpr; + readonly right: CExpr; + readonly typeArgs: TypeArgs; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type COpUnary = { + readonly kind: "op_unary"; + readonly op: UnaryOperation; + readonly operand: CExpr; + readonly typeArgs: TypeArgs; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CFieldAccess = { + readonly kind: "field_access"; + readonly aggregate: CExpr; + readonly field: Id; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CMethodCall = { + readonly kind: "method_call"; + readonly self: CExpr; + readonly method: Id; + // NB! these are substitutions to self type + readonly args: readonly CExpr[]; + readonly typeArgs: TypeArgs; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +// builtins or top-level (module) functions +export type CStaticCall = { + readonly kind: "static_call"; + readonly function: Id; + readonly typeArgs: TypeArgs; + readonly args: readonly CExpr[]; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CStaticMethodCall = { + readonly kind: "static_method_call"; + readonly self: TypeId; + readonly typeArgs: TypeArgs; + readonly function: Id; + readonly args: readonly CExpr[]; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CStructCons = { + readonly kind: "struct_instance"; + readonly fields: Ordered>; + readonly computedType: D.CTRef | D.CTRecover; + readonly loc: Loc; +}; + +export type CMapLiteral = { + readonly kind: "map_literal"; + readonly fields: readonly DMapField[]; + readonly computedType: D.CTMap; + readonly loc: Loc; +}; + +export type DMapField = { + readonly key: CExpr; + readonly value: CExpr; +}; + +export type CSetLiteral = { + readonly kind: "set_literal"; + readonly valueType: D.CType; + readonly fields: readonly CExpr[]; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CInitOf = { + readonly kind: "init_of"; + readonly contract: TypeId; + readonly args: readonly CExpr[]; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CCodeOf = { + readonly kind: "code_of"; + readonly contract: TypeId; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CConditional = { + readonly kind: "conditional"; + readonly condition: CExpr; + readonly thenBranch: CExpr; + readonly elseBranch: CExpr; + readonly computedType: D.CType; + readonly loc: Loc; +}; + +export type CUnit = { + readonly kind: "unit"; + readonly computedType: D.CTBasic; + readonly loc: Loc; +}; + +export type CTuple = { + readonly kind: "tuple"; + readonly children: readonly CExpr[]; + readonly computedType: D.CTTuple; + readonly loc: Loc; +}; + +export type CTensor = { + readonly kind: "tensor"; + readonly children: readonly CExpr[]; + readonly computedType: D.CTTensor; + readonly loc: Loc; +}; diff --git a/src/next/ast/checked-stmt.ts b/src/next/ast/checked-stmt.ts new file mode 100644 index 0000000000..af91dde93b --- /dev/null +++ b/src/next/ast/checked-stmt.ts @@ -0,0 +1,125 @@ +import type { CExpr, CLValue } from "@/next/ast/checked-expr"; +import type { Id, Loc, OptionalId, TypeId } from "@/next/ast/common"; +import type { Ordered } from "@/next/ast/generated/common"; +import type { AugmentedAssignOperation } from "@/next/ast/statement"; + +export type CStmt = + | CStmtLet + | CStmtReturn + | CStmtExpression + | CStmtAssign + | CStmtAugmentedAssign + | CStmtCondition + | CStmtWhile + | CStmtUntil + | CStmtRepeat + | CStmtTry + | CStmtForEach + | CStmtDestruct + | CStmtBlock; + +export type CStmtList = readonly CStmt[]; + +export type CStmtLet = { + readonly kind: "statement_let"; + readonly name: OptionalId; + readonly expression: CExpr; + readonly loc: Loc; +}; + +export type CStmtReturn = { + readonly kind: "statement_return"; + readonly expression: CExpr | undefined; + readonly loc: Loc; +}; + +export type CStmtExpression = { + readonly kind: "statement_expression"; + readonly expression: CExpr; + readonly loc: Loc; +}; + +export type CStmtAssign = { + readonly kind: "statement_assign"; + readonly path: CLValue; + readonly expression: CExpr; + readonly loc: Loc; +}; + +export type CStmtAugmentedAssign = { + readonly kind: "statement_augmentedassign"; + readonly op: AugmentedAssignOperation; + readonly path: CLValue; + readonly expression: CExpr; + readonly loc: Loc; +}; + +export type CStmtCondition = { + readonly kind: "statement_condition"; + readonly condition: CExpr; + readonly trueStatements: CStmtList; + readonly falseStatements: CStmtList | undefined; + readonly loc: Loc; +}; + +export type CStmtWhile = { + readonly kind: "statement_while"; + readonly condition: CExpr; + readonly statements: CStmtList; + readonly loc: Loc; +}; + +export type CStmtUntil = { + readonly kind: "statement_until"; + readonly condition: CExpr; + readonly statements: CStmtList; + readonly loc: Loc; +}; + +export type CStmtRepeat = { + readonly kind: "statement_repeat"; + readonly iterations: CExpr; + readonly statements: CStmtList; + readonly loc: Loc; +}; + +export type CStmtTry = { + readonly kind: "statement_try"; + readonly statements: CStmtList; + readonly catchBlock: CCatchBlock | undefined; + readonly loc: Loc; +}; + +export type CCatchBlock = { + readonly name: OptionalId; + readonly statements: CStmtList; +}; + +export type CStmtForEach = { + readonly kind: "statement_foreach"; + readonly keyName: OptionalId; + readonly valueName: OptionalId; + readonly map: CExpr; + readonly statements: CStmtList; + readonly loc: Loc; +}; + +export type CStmtDestruct = { + readonly kind: "statement_destruct"; + readonly type: TypeId; + readonly identifiers: Ordered; + readonly ignoreUnspecifiedFields: boolean; + readonly expression: CExpr; + readonly loc: Loc; +}; + +export type CDestructPattern = { + readonly field: Id; + readonly variable: OptionalId; +}; + +export type CStmtBlock = { + readonly kind: "statement_block"; + readonly statements: CStmtList; + readonly loc: Loc; +}; diff --git a/src/next/ast/checked-type.ts b/src/next/ast/checked-type.ts new file mode 100644 index 0000000000..04bd99bde6 --- /dev/null +++ b/src/next/ast/checked-type.ts @@ -0,0 +1,89 @@ +import type { CTypeDeclRefable } from "@/next/ast/checked"; +import type { Loc, TypeId } from "@/next/ast/common"; +import type { BasicType } from "@/next/ast/type-basic"; + +export type CNotSet = { + readonly kind: "not-set"; +}; + +export type CType = + | CTRecover + | CTRef + | CTAliasRef + | CTParamRef + | CTMap + | CTBounced + | CTMaybe + | CTTuple + | CTTensor + | CTBasic; + +export type CTBasic = { + readonly kind: "basic"; + readonly type: BasicType; + readonly loc: Loc; +}; + +export type CTRecover = { + readonly kind: "recover"; +}; + +export type CNotDealiased = { + readonly kind: "NotDealiased"; +}; + +export type CTRef = { + readonly kind: "type_ref"; + readonly name: TypeId; + readonly type: CTypeDeclRefable; + readonly typeArgs: readonly CType[]; + // readonly funcType: Lazy; + // readonly alloc: Lazy + readonly loc: Loc; +}; + +export type CTAliasRef = { + readonly kind: "TypeAlias"; + readonly name: TypeId; + readonly type: CNotDealiased | CType; + readonly typeArgs: readonly CType[]; + readonly loc: Loc; +}; + +export type CTParamRef = { + readonly kind: "TypeParam"; + readonly name: TypeId; + readonly loc: Loc; +}; + +export type CTBounced = { + readonly kind: "TypeBounced"; + // name of the message type + readonly name: TypeId; + readonly loc: Loc; +}; + +export type CTMaybe = { + readonly kind: "TypeMaybe"; + readonly type: CType; + readonly loc: Loc; +}; + +export type CTMap = { + readonly kind: "map_type"; + readonly key: CType; + readonly value: CType; + readonly loc: Loc; +}; + +export type CTTuple = { + readonly kind: "tuple_type"; + readonly typeArgs: readonly CType[]; + readonly loc: Loc; +}; + +export type CTTensor = { + readonly kind: "tensor_type"; + readonly typeArgs: readonly CType[]; + readonly loc: Loc; +}; diff --git a/src/next/ast/checked.ts b/src/next/ast/checked.ts new file mode 100644 index 0000000000..b11782b231 --- /dev/null +++ b/src/next/ast/checked.ts @@ -0,0 +1,262 @@ +import type { CStmt } from "@/next/ast/checked-stmt"; +import type { FuncId, Loc, OptionalId, Ordered, TypeId } from "@/next/ast/common"; +import type { CType, CTRef, CTBounced } from "@/next/ast/checked-type"; +import type { Effects } from "@/next/ast/effects"; +import type { Thunk } from "@/next/ast/lazy"; +import type { SelfType } from "@/next/ast/type-self"; +import type { + AsmInstruction, + AsmShuffle, + ContractAttribute, +} from "@/next/ast/root"; +import type { Value } from "@/next/ast/value"; +import type { ViaMember, ViaUser } from "@/next/ast/via"; +import type { TactImport } from "@/next/imports/source"; + +export type SourceCheckResult = { + // import that lead to reading this file + readonly importedBy: TactImport; + // scopes that were computed from this file + readonly globals: CSource; +}; + +export type CSource = { + readonly typeDecls: ReadonlyMap>; + readonly functions: ReadonlyMap>; + readonly constants: ReadonlyMap>; + readonly extensions: ReadonlyMap[]>>; +}; + +export type Decl = { + readonly decl: T; + readonly via: ViaUser; +}; + +export type Recover = T | undefined; + +export type CTypeDecl = + | CAlias + | CContract + | CTrait + | CStruct + | CMessage + | CUnion; + +export type CTypeDeclRefable = + | CContract + | CTrait + | CStruct + | CMessage + | CUnion; + +export type CConstant = { + readonly initializer: Thunk>; + readonly type: Thunk; +}; + +export type CFunction = { + readonly type: CTFunction; + readonly inline: boolean; + readonly body: CBody; +}; + +export type CStatements = Thunk>; + +export type CStatementsAux = { + readonly body: readonly CStmt[]; + readonly effects: Effects; +}; + +export type CBody = CTactBody | CFuncBody | CFiftBody; + +export type CTactBody = { + readonly kind: "tact"; + readonly statements: CStatements; +}; +export type CFuncBody = { + readonly kind: "func"; + readonly nativeName: FuncId; +}; +export type CFiftBody = { + readonly kind: "fift"; + readonly shuffle: Thunk>; + readonly instructions: readonly AsmInstruction[]; +}; + +export type CExtension = { + readonly type: CTMethod; + readonly inline: boolean; + readonly body: CBody; +}; + +export type CAlias = { + readonly kind: "alias"; + readonly typeParams: CTypeParams; + readonly type: Thunk; +}; + +export type CInit = CInitEmpty | CInitSimple | CInitFn; +export type CInitEmpty = { + readonly kind: "empty"; + // initOf() would take 0 parameters + // values to fill all the fields + readonly fill: Thunk>>>>; +}; +export type CInitSimple = { + readonly kind: "simple"; + // initOf() takes these parameters and + // sets them into correspondingly named fields + readonly fill: Ordered; + readonly loc: Loc; +}; +export type CInitFn = { + readonly kind: "function"; + // here we just specify the function + readonly params: CParameters; + readonly statements: CStatements; +}; +export type CInitParam = { + readonly type: Thunk; + readonly init: undefined | Thunk>; + readonly loc: Loc; +}; + +export type CContract = { + readonly kind: "contract"; + readonly attributes: readonly ContractAttribute[]; + readonly init: CInit; + readonly content: Thunk; +}; +export type CContractMembers = CMembers>, CBody>; +export type CTrait = { + readonly kind: "trait"; + readonly content: Thunk; +}; +export type CTraitMembers = CMembers< + Thunk> | undefined, + CBody | undefined +>; +export type CMembers = { + readonly fieldish: Ordered>>; + readonly methods: ReadonlyMap>>; + readonly receivers: CReceivers; +}; +export type CReceivers = { + readonly bounce: CBounce; + readonly internal: CReceiver; + readonly external: CReceiver; +}; + +export type CFieldish = CField | CFieldConstant; +export type CField = { + readonly kind: "field"; + readonly type: Thunk; + readonly init: Thunk> | undefined; +}; +export type CFieldConstant = { + readonly kind: "constant"; + readonly overridable: boolean; + readonly type: Thunk; + readonly init: Expr; +}; + +export type CMethod = { + readonly overridable: boolean; + readonly type: CTMethod; + readonly inline: boolean; + readonly body: Body; + readonly getMethodId: Thunk> | undefined; +}; + +export type CBounce = { + // NB! can't compute opcodes until all receivers are present + readonly message: readonly DeclMem[]; + readonly messageAny: undefined | DeclMem; +}; + +export type CReceiver = { + // NB! can't compute opcodes until all receivers are present + readonly message: readonly DeclMem[]; + readonly messageAny: undefined | DeclMem; + readonly stringAny: undefined | DeclMem; + readonly empty: undefined | DeclMem; +}; + +export type CReceiverOpcode = CReceiverMessage | CReceiverString; +export type CReceiverMessage = { + readonly kind: "binary"; + readonly name: OptionalId; + readonly type: CTRef | CTBounced; + readonly statements: CStatements; +}; +export type CReceiverMessageAny = { + readonly name: OptionalId; + readonly statements: CStatements; +}; +export type CReceiverString = { + readonly kind: "string"; + readonly comment: string; + readonly statements: CStatements; +}; +export type CReceiverStringAny = { + readonly name: OptionalId; + readonly statements: CStatements; +}; +export type CReceiverEmpty = { + readonly statements: CStatements; +}; + +export type DeclMem = { + readonly decl: T; + readonly via: ViaMember; +}; + +export type CStruct = { + readonly kind: "struct"; + readonly typeParams: CTypeParams; + readonly fields: Ordered; +}; + +export type CMessage = { + readonly kind: "message"; + readonly opcode: Thunk>; + readonly fields: Ordered; +}; + +export type CUnion = { + readonly kind: "union"; + readonly typeParams: CTypeParams; + readonly cases: ReadonlyMap>; +}; + +export type CTFunction = { + readonly kind: "DecodedFnType"; + readonly typeParams: CTypeParams; + readonly params: CParameters; + readonly returnType: Thunk; +}; + +export type CTMethod = { + readonly kind: "DecodedMethodType"; + readonly mutates: boolean; + readonly typeParams: CTypeParams; + readonly self: SelfType; + readonly params: CParameters; + readonly returnType: Thunk; +}; + +export type CParameter = { + readonly name: OptionalId; + readonly type: Thunk; + readonly loc: Loc; +}; + +export type CParameters = { + readonly order: readonly CParameter[]; + readonly set: ReadonlySet; +}; + +export type CTypeParams = { + readonly order: readonly TypeId[]; + readonly set: ReadonlySet; +}; diff --git a/src/next/ast/common.ts b/src/next/ast/common.ts new file mode 100644 index 0000000000..aa0504a93f --- /dev/null +++ b/src/next/ast/common.ts @@ -0,0 +1,45 @@ +export type Loc = Range | Builtin; + +export type Builtin = { + readonly kind: "builtin"; +}; + +export type Range = { + readonly kind: "range"; + readonly start: number; + readonly end: number; + readonly path: string; + readonly code: string; +}; + +export type OptionalId = Id | Wildcard; + +export type Id = { + readonly kind: "id"; + readonly text: string; + readonly loc: Loc; +}; + +export type Wildcard = { + readonly kind: "wildcard"; + readonly loc: Loc; +}; + +export type FuncId = { + readonly kind: "func_id"; + readonly text: string; + readonly loc: Loc; +}; + +export type TypeId = { + readonly kind: "type_id"; + readonly text: string; + readonly loc: Loc; +}; + +export type Language = "func" | "tact"; + +export type Ordered = { + readonly order: readonly string[]; + readonly map: ReadonlyMap; +}; \ No newline at end of file diff --git a/src/next/ast/effects.ts b/src/next/ast/effects.ts new file mode 100644 index 0000000000..cb616eefe2 --- /dev/null +++ b/src/next/ast/effects.ts @@ -0,0 +1,17 @@ +import type { Loc } from "@/next/ast"; + +export type Effects = { + // throws at all times + readonly mustThrow: boolean; + // maybe reads from storage + readonly mayRead: boolean; + // maybe writes to storage + readonly mayWrite: boolean; + // which self.* were assigned to + readonly mustSetSelf: ReadonlySet; +} + +export type Returns = { + readonly selfSet: ReadonlySet; + readonly loc: Loc +} diff --git a/src/next/ast/errors.ts b/src/next/ast/errors.ts new file mode 100644 index 0000000000..a3673debc7 --- /dev/null +++ b/src/next/ast/errors.ts @@ -0,0 +1,173 @@ +import { throwInternal } from "@/error/errors"; +import type { CType } from "@/next/ast/checked-type"; +import type { Loc } from "@/next/ast/common"; +import type * as V from "@/next/ast/via"; + +export type Log = Generator; + +export function runLog( + gen: Generator, +): readonly [R, readonly T[]] { + const yields: T[] = []; + for (;;) { + const result = gen.next(); + if (result.done) { + return [result.value, yields]; + } else { + yields.push(result.value); + } + } +} + +export function* mapLog( + xs: readonly T[], + f: (x: T) => Log, +): Log { + const result: U[] = []; + for (const x of xs) { + result.push(yield* f(x)); + } + return result; +} + +export function* reduceLog( + xs: readonly T[], + init: U, + f: (acc: U, x: T) => Log, +): Log { + let acc = init; + for (const x of xs) { + acc = yield* f(acc, x); + } + return acc; +} + +export function* filterLog( + xs: readonly T[], + f: (x: T) => Log, +): Log { + const result: T[] = []; + for (const x of xs) { + const res = yield* f(x); + if (res) { + result.push(x); + } + } + return result; +} + +export function* toMap( + kind: string, + xs: readonly (readonly [string, V])[], +): Log> { + const result: Map = new Map(); + for (const [key, next] of xs) { + const prev = result.get(key); + if (prev) { + yield ERedefine(kind, key, next.via, prev.via); + } else { + result.set(key, next); + } + } + return result; +} + +export type TcError = { + // location where IDE should show this error + readonly loc: Loc; + // text description + readonly descr: readonly TELine[]; +}; +export const TcError = ( + loc: Loc, + ...descr: readonly TELine[] +): TcError => { + debugger; + return { loc, descr }; +}; + +export type TELine = TEText | TEVia | TEViaMember | TECode | TEMismatch; + +export type TEText = { + readonly kind: "text"; + readonly text: string; +}; +export const TEText = (text: string): TEText => ({ kind: "text", text }); + +export type TEVia = { + readonly kind: "via"; + readonly via: V.Via; +}; +export const TEVia = (via: V.Via): TEVia => ({ kind: "via", via }); + +export type TEViaMember = { + readonly kind: "via-member"; + readonly via: V.ViaMember; +}; +export const TEViaMember = (via: V.ViaMember): TEViaMember => ({ + kind: "via-member", + via, +}); + +export type TECode = { + readonly kind: "code"; + readonly loc: Loc; +}; +export const TECode = (loc: Loc): TECode => ({ kind: "code", loc }); + +export type TEMismatch = { + readonly kind: "mismatch"; + readonly tree: MatchTree; +}; +export const TEMismatch = (tree: MatchTree): TEMismatch => ({ + kind: "mismatch", + tree, +}); + +export type MatchTree = { + readonly expected: CType; + readonly got: CType; + readonly children: readonly MatchTree[]; +}; +export const MatchTree = ( + expected: CType, + got: CType, + children: readonly MatchTree[], +): MatchTree => ({ expected, got, children }); + +export const viaToRange = ({ imports, defLoc: definedAt }: V.ViaUser): Loc => { + const [head] = imports; + if (typeof head === "undefined") { + return definedAt; + } + const { loc } = head; + if (loc.kind === "range") { + return loc; + } + return throwInternal( + "Implicit import shadows something. Duplicates in stdlib?", + ); +}; + +export const ERedefine = ( + kind: string, + name: string, + prev: V.Via, + next: V.ViaUser, +) => TcError( + viaToRange(next), + TEText(`There already is a ${kind} "${name}" from`), TEVia(prev), +); + +export const ERedefineMember = ( + name: string, + prev: V.ViaMember, + next: V.ViaMember, +) => TcError( + next.defLoc, + TEText(`"${name}" is inherited twice`), + TEText(`First defined at`), + TEViaMember(prev), + TEText(`Redefined at`), + TEViaMember(next), +); diff --git a/src/next/ast/expression.ts b/src/next/ast/expression.ts new file mode 100644 index 0000000000..e045231b96 --- /dev/null +++ b/src/next/ast/expression.ts @@ -0,0 +1,202 @@ +import type { Id, Loc, TypeId } from "@/next/ast/common"; +import type { Type, TMap } from "@/next/ast/type"; + +export type Expression = + | OpBinary + | OpUnary + | Conditional + | MethodCall + | StaticCall + | StaticMethodCall + | FieldAccess + | StructInstance + | InitOf + | CodeOf + | Number + | Boolean + | Null + | String + | Var + | Unit + | Tuple + | Tensor + | MapLiteral + | SetLiteral; + +export type Var = { + readonly kind: "var"; + readonly name: string; + readonly loc: Loc; +}; + +export type Number = { + readonly kind: "number"; + readonly base: NumberBase; + readonly value: bigint; + readonly loc: Loc; +}; + +export type NumberBase = "2" | "8" | "10" | "16"; + +export type Boolean = { + readonly kind: "boolean"; + readonly value: boolean; + readonly loc: Loc; +}; + +// A String is a string in which escaping characters, like '\\' has been simplified, e.g., '\\' simplified to '\'. +export type String = { + readonly kind: "string"; + readonly value: string; + readonly loc: Loc; +}; + +// `null` value is an inhabitant of several types: +// it can represent missing values in optional types, +// or empty map of any key and value types +export type Null = { + readonly kind: "null"; + readonly loc: Loc; +}; + +export type BinaryOperation = + | "+" + | "-" + | "*" + | "/" + | "!=" + | ">" + | "<" + | ">=" + | "<=" + | "==" + | "&&" + | "||" + | "%" + | "<<" + | ">>" + | "&" + | "|" + | "^"; + +export type OpBinary = { + readonly kind: "op_binary"; + readonly op: BinaryOperation; + readonly left: Expression; + readonly right: Expression; + readonly loc: Loc; +}; + +export type UnaryOperation = "+" | "-" | "!" | "!!" | "~"; + +export type OpUnary = { + readonly kind: "op_unary"; + readonly op: UnaryOperation; + readonly operand: Expression; + readonly loc: Loc; +}; + +export type FieldAccess = { + readonly kind: "field_access"; + readonly aggregate: Expression; // contract, trait, struct, message + readonly field: Id; + readonly loc: Loc; +}; + +export type MethodCall = { + readonly kind: "method_call"; + readonly self: Expression; // anything with a method + readonly method: Id; + readonly args: readonly Expression[]; + readonly loc: Loc; +}; + +// builtins or top-level (module) functions +export type StaticCall = { + readonly kind: "static_call"; + readonly function: Id; + readonly typeArgs: readonly Type[]; + readonly args: readonly Expression[]; + readonly loc: Loc; +}; + +export type StaticMethodCall = { + readonly kind: "static_method_call"; + readonly self: TypeId; + readonly typeArgs: readonly Type[]; + readonly function: Id; + readonly args: readonly Expression[]; + readonly loc: Loc; +}; + +export type StructInstance = { + readonly kind: "struct_instance"; + readonly type: TypeId; + readonly typeArgs: readonly Type[]; + readonly args: readonly StructFieldInitializer[]; + readonly loc: Loc; +}; + +export type StructFieldInitializer = { + readonly kind: "struct_field_initializer"; + readonly field: Id; + readonly initializer: Expression; + readonly loc: Loc; +}; + +export type MapLiteral = { + readonly kind: "map_literal"; + readonly type: TMap; + readonly fields: readonly MapField[]; + readonly loc: Loc; +}; + +export type MapField = { + readonly key: Expression; + readonly value: Expression; +}; + +export type SetLiteral = { + readonly kind: "set_literal"; + readonly valueType: Type; + readonly fields: readonly Expression[]; + readonly loc: Loc; +}; + +export type InitOf = { + readonly kind: "init_of"; + readonly contract: TypeId; + readonly args: readonly Expression[]; + readonly loc: Loc; +}; + +export type CodeOf = { + readonly kind: "code_of"; + readonly contract: TypeId; + readonly loc: Loc; +}; + +export type Conditional = { + readonly kind: "conditional"; + readonly condition: Expression; + readonly thenBranch: Expression; + readonly elseBranch: Expression; + readonly loc: Loc; +}; + +export type Unit = { + readonly kind: "unit"; + readonly loc: Loc; +}; + +export type Tuple = { + readonly kind: "tuple"; + readonly children: readonly Expression[]; + readonly loc: Loc; +}; + +export type Tensor = { + readonly kind: "tensor"; + readonly children: readonly Expression[]; + readonly loc: Loc; +}; diff --git a/src/next/ast/generated/checked-expr.ts b/src/next/ast/generated/checked-expr.ts new file mode 100644 index 0000000000..4094b34a42 --- /dev/null +++ b/src/next/ast/generated/checked-expr.ts @@ -0,0 +1,327 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $ from "@/next/ast/checked-expr"; +import type * as $c from "@/next/ast/common"; +import type * as $d from "@/next/ast/checked-type"; +import type * as $e from "@/next/ast/expression"; +import type { SelfType } from "@/next/ast/type-self"; + +export type CCodeOf = $.CCodeOf; +export const CCodeOf = ( + contract: $c.TypeId, + computedType: $d.CType, + loc: $c.Loc, +): $.CCodeOf => + Object.freeze({ + kind: "code_of", + contract, + computedType, + loc, + }); +export type CNumber = $.CNumber; +export const DNumber = ( + base: $e.NumberBase, + value: bigint, + computedType: $d.CTBasic, + loc: $c.Loc, +): $.CNumber => + Object.freeze({ + kind: "number", + base, + value, + computedType, + loc, + }); +export type CBoolean = $.CBoolean; +export const CBoolean = ( + value: boolean, + computedType: $d.CTBasic, + loc: $c.Loc, +): $.CBoolean => + Object.freeze({ + kind: "boolean", + value, + computedType, + loc, + }); +export type CNull = $.CNull; +export const CNull = (computedType: $d.CTBasic, loc: $c.Loc): $.CNull => + Object.freeze({ + kind: "null", + computedType, + loc, + }); +export type CString = $.CString; +export const CString = ( + value: string, + computedType: $d.CTBasic, + loc: $c.Loc, +): $.CString => + Object.freeze({ + kind: "string", + value, + computedType, + loc, + }); +export type CVar = $.CVar; +export const CVar = ( + name: string, + computedType: $d.CType, + loc: $c.Loc, +): $.CVar => + Object.freeze({ + kind: "var", + name, + computedType, + loc, + }); +export type CSelf = $.CSelf; +export const CSelf = (computedType: SelfType, loc: $c.Loc): $.CSelf => + Object.freeze({ + kind: "self", + computedType, + loc, + }); +export type CUnit = $.CUnit; +export const CUnit = (computedType: $d.CTBasic, loc: $c.Loc): $.CUnit => + Object.freeze({ + kind: "unit", + computedType, + loc, + }); +export type CSetLiteral = $.CSetLiteral; +export const CSetLiteral = ( + valueType: $d.CType, + computedType: $d.CType, + fields: readonly $.CExpr[], + loc: $c.Loc, +): $.CSetLiteral => + Object.freeze({ + kind: "set_literal", + valueType, + fields, + computedType, + loc, + }); +export type CMapField = $.DMapField; +export const CMapField = ( + key: $.CExpr, + value: $.CExpr, +): $.DMapField => + Object.freeze({ + key, + value, + }); +export type CMapLiteral = $.CMapLiteral; +export const CMapLiteral = ( + computedType: $d.CTMap, + fields: readonly $.DMapField[], + loc: $c.Loc, +): $.CMapLiteral => + Object.freeze({ + kind: "map_literal", + fields, + computedType, + loc, + }); +export type CTensor = $.CTensor; +export const CTensor = ( + children: readonly $.CExpr[], + computedType: $d.CTTensor, + loc: $c.Loc, +): $.CTensor => + Object.freeze({ + kind: "tensor", + children, + computedType, + loc, + }); +export type CTuple = $.CTuple; +export const CTuple = ( + children: readonly $.CExpr[], + computedType: $d.CTTuple, + loc: $c.Loc, +): $.CTuple => + Object.freeze({ + kind: "tuple", + children, + computedType, + loc, + }); +export type CInitOf = $.CInitOf; +export const CInitOf = ( + contract: $c.TypeId, + args: readonly $.CExpr[], + computedType: $d.CType, + loc: $c.Loc, +): $.CInitOf => + Object.freeze({ + kind: "init_of", + contract, + args, + computedType, + loc, + }); +export type CStructCons = $.CStructCons; +export const CStructCons = ( + fields: $c.Ordered, + computedType: $d.CTRef | $d.CTRecover, + loc: $c.Loc, +): $.CStructCons => + Object.freeze({ + kind: "struct_instance", + fields, + computedType, + loc, + }); +export type CFieldAccess = $.CFieldAccess; +export const CFieldAccess = ( + aggregate: $.CExpr, + field: $c.Id, + computedType: $d.CType, + loc: $c.Loc, +): $.CFieldAccess => + Object.freeze({ + kind: "field_access", + aggregate, + field, + computedType, + loc, + }); +export type CStaticMethodCall = $.CStaticMethodCall; +export const CStaticMethodCall = ( + self: $c.TypeId, + typeArgs: $.TypeArgs, + function_: $c.Id, + args: readonly $.CExpr[], + computedType: $d.CType, + loc: $c.Loc, +): $.CStaticMethodCall => + Object.freeze({ + kind: "static_method_call", + self, + typeArgs, + function: function_, + args, + computedType, + loc, + }); +export type TypeArgs = $.TypeArgs; +export type CStaticCall = $.CStaticCall; +export const CStaticCall = ( + function_: $c.Id, + typeArgs: $.TypeArgs, + args: readonly $.CExpr[], + computedType: $d.CType, + loc: $c.Loc, +): $.CStaticCall => + Object.freeze({ + kind: "static_call", + function: function_, + typeArgs, + args, + computedType, + loc, + }); +export type CMethodCall = $.CMethodCall; +export const CMethodCall = ( + self: $.CExpr, + method: $c.Id, + args: readonly $.CExpr[], + typeArgs: $.TypeArgs, + computedType: $d.CType, + loc: $c.Loc, +): $.CMethodCall => + Object.freeze({ + kind: "method_call", + self, + method, + typeArgs, + args, + computedType, + loc, + }); +export type CConditional = $.CConditional; +export const CConditional = ( + condition: $.CExpr, + thenBranch: $.CExpr, + elseBranch: $.CExpr, + computedType: $d.CType, + loc: $c.Loc, +): $.CConditional => + Object.freeze({ + kind: "conditional", + condition, + thenBranch, + elseBranch, + computedType, + loc, + }); +export type COpUnary = $.COpUnary; +export const COpUnary = ( + op: $e.UnaryOperation, + operand: $.CExpr, + typeArgs: ReadonlyMap, + computedType: $d.CType, + loc: $c.Loc, +): $.COpUnary => + Object.freeze({ + kind: "op_unary", + op, + operand, + typeArgs, + computedType, + loc, + }); +export type COpBinary = $.COpBinary; +export const COpBinary = ( + op: $e.BinaryOperation, + left: $.CExpr, + right: $.CExpr, + typeArgs: ReadonlyMap, + computedType: $d.CType, + loc: $c.Loc, +): $.COpBinary => + Object.freeze({ + kind: "op_binary", + op, + left, + right, + typeArgs, + computedType, + loc, + }); +export type CExpr = $.CExpr; +export type CLVar = $.CLVar; +export const CLVar = ( + name: string, + computedType: $d.CType, + loc: $c.Loc, +): $.CLVar => + Object.freeze({ + kind: "var", + name, + computedType, + loc, + }); +export type CLSelf = $.CLSelf; +export const CLSelf = (computedType: SelfType, loc: $c.Loc): $.CLSelf => + Object.freeze({ + kind: "self", + computedType, + loc, + }); +export type CLFieldAccess = $.CLFieldAccess; +export const CLFieldAccess = ( + aggregate: $.CLValue, + field: $c.Id, + computedType: $d.CType, + loc: $c.Loc, +): $.CLFieldAccess => + Object.freeze({ + kind: "field_access", + aggregate, + field, + computedType, + loc, + }); +export type LValue = $.CLValue; diff --git a/src/next/ast/generated/checked-stmt.ts b/src/next/ast/generated/checked-stmt.ts new file mode 100644 index 0000000000..ff6e7d0d7a --- /dev/null +++ b/src/next/ast/generated/checked-stmt.ts @@ -0,0 +1,188 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $ from "@/next/ast/checked-stmt"; +import type * as $e from "@/next/ast/checked-expr"; +import type * as $c from "@/next/ast/common"; +import type * as $s from "@/next/ast/statement"; + +export type CStmtLet = $.CStmtLet; +export const CStmtLet = ( + name: $c.OptionalId, + expression: $e.CExpr, + loc: $c.Loc, +): $.CStmtLet => + Object.freeze({ + kind: "statement_let", + name, + expression, + loc, + }); +export type CStmtReturn = $.CStmtReturn; +export const CStmtReturn = ( + expression: $e.CExpr | undefined, + loc: $c.Loc, +): $.CStmtReturn => + Object.freeze({ + kind: "statement_return", + expression, + loc, + }); +export type CStmtExpression = $.CStmtExpression; +export const CStmtExpression = ( + expression: $e.CExpr, + loc: $c.Loc, +): $.CStmtExpression => + Object.freeze({ + kind: "statement_expression", + expression, + loc, + }); +export type CStmtAssign = $.CStmtAssign; +export const CStmtAssign = ( + path: $e.CLValue, + expression: $e.CExpr, + loc: $c.Loc, +): $.CStmtAssign => + Object.freeze({ + kind: "statement_assign", + path, + expression, + loc, + }); +export type CStmtAugmentedAssign = $.CStmtAugmentedAssign; +export const CStmtAugmentedAssign = ( + op: $s.AugmentedAssignOperation, + path: $e.CLValue, + expression: $e.CExpr, + loc: $c.Loc, +): $.CStmtAugmentedAssign => + Object.freeze({ + kind: "statement_augmentedassign", + op, + path, + expression, + loc, + }); +export type CDestructPattern = $.CDestructPattern; +export const CDestructPattern = ( + field: $c.Id, + variable: $c.OptionalId, +): $.CDestructPattern => + Object.freeze({ + field, + variable, + }); +export type CStmtDestruct = $.CStmtDestruct; +export const CStmtDestruct = ( + type_: $c.TypeId, + identifiers: $c.Ordered<$.CDestructPattern>, + ignoreUnspecifiedFields: boolean, + expression: $e.CExpr, + loc: $c.Loc, +): $.CStmtDestruct => + Object.freeze({ + kind: "statement_destruct", + type: type_, + identifiers, + ignoreUnspecifiedFields, + expression, + loc, + }); +export type CStmtBlock = $.CStmtBlock; +export const CStmtBlock = ( + statements: $.CStmtList, + loc: $c.Loc, +): $.CStmtBlock => + Object.freeze({ + kind: "statement_block", + statements, + loc, + }); +export type CStmtForEach = $.CStmtForEach; +export const CStmtForEach = ( + keyName: $c.OptionalId, + valueName: $c.OptionalId, + map: $e.CExpr, + statements: $.CStmtList, + loc: $c.Loc, +): $.CStmtForEach => + Object.freeze({ + kind: "statement_foreach", + keyName, + valueName, + map, + statements, + loc, + }); +export type CCatchBlock = $.CCatchBlock; +export const CCatchBlock = ( + catchName: $c.OptionalId, + catchStatements: $.CStmtList, +): $.CCatchBlock => + Object.freeze({ + name: catchName, + statements: catchStatements, + }); +export type CStmtTry = $.CStmtTry; +export const CStmtTry = ( + statements: $.CStmtList, + catchBlock: $.CCatchBlock | undefined, + loc: $c.Loc, +): $.CStmtTry => + Object.freeze({ + kind: "statement_try", + statements, + catchBlock, + loc, + }); +export type CStmtRepeat = $.CStmtRepeat; +export const CStmtRepeat = ( + iterations: $e.CExpr, + statements: $.CStmtList, + loc: $c.Loc, +): $.CStmtRepeat => + Object.freeze({ + kind: "statement_repeat", + iterations, + statements, + loc, + }); +export type CStmtUntil = $.CStmtUntil; +export const CStmtUntil = ( + condition: $e.CExpr, + statements: $.CStmtList, + loc: $c.Loc, +): $.CStmtUntil => + Object.freeze({ + kind: "statement_until", + condition, + statements, + loc, + }); +export type CStmtWhile = $.CStmtWhile; +export const CStmtWhile = ( + condition: $e.CExpr, + statements: $.CStmtList, + loc: $c.Loc, +): $.CStmtWhile => + Object.freeze({ + kind: "statement_while", + condition, + statements, + loc, + }); +export type CStmtList = $.CStmtList; +export type CStmtCondition = $.CStmtCondition; +export const CStmtCondition = ( + condition: $e.CExpr, + trueStatements: $.CStmtList, + falseStatements: $.CStmtList | undefined, + loc: $c.Loc, +): $.CStmtCondition => + Object.freeze({ + kind: "statement_condition", + condition, + trueStatements, + falseStatements, + loc, + }); +export type CStmt = $.CStmt; diff --git a/src/next/ast/generated/checked-type.ts b/src/next/ast/generated/checked-type.ts new file mode 100644 index 0000000000..db6ac372c7 --- /dev/null +++ b/src/next/ast/generated/checked-type.ts @@ -0,0 +1,111 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $ from "@/next/ast/checked-type"; +import type * as $c from "@/next/ast/common"; +import type { CTypeDeclRefable } from "@/next/ast/checked"; +import type { BasicType } from "@/next/ast/type-basic"; + +export type CTBasic = $.CTBasic; +export const CTBasic = (type: BasicType, loc: $c.Loc): $.CTBasic => + Object.freeze({ + kind: "basic", + type, + loc, + }); +export type CTParamRef = $.CTParamRef; +export const CTParamRef = (name: $c.TypeId, loc: $c.Loc): $.CTParamRef => + Object.freeze({ + kind: "TypeParam", + name, + loc, + }); +export type CTTensor = $.CTTensor; +export const CTTensor = ( + typeArgs: readonly $.CType[], + loc: $c.Loc, +): $.CTTensor => + Object.freeze({ + kind: "tensor_type", + typeArgs, + loc, + }); +export type CTTuple = $.CTTuple; +export const CTTuple = ( + typeArgs: readonly $.CType[], + loc: $c.Loc, +): $.CTTuple => + Object.freeze({ + kind: "tuple_type", + typeArgs, + loc, + }); +export type CTMaybe = $.CTMaybe; +export const CTMaybe = (type_: $.CType, loc: $c.Loc): $.CTMaybe => + Object.freeze({ + kind: "TypeMaybe", + type: type_, + loc, + }); +export type CTBounced = $.CTBounced; +export const CTBounced = (name: $c.TypeId, loc: $c.Loc): $.CTBounced => + Object.freeze({ + kind: "TypeBounced", + name, + loc, + }); +export type CTMap = $.CTMap; +export const CTMap = ( + key: $.CType, + value: $.CType, + loc: $c.Loc, +): $.CTMap => + Object.freeze({ + kind: "map_type", + key, + value, + loc, + }); +export type CTAliasRef = $.CTAliasRef; +export const CTAliasRef = ( + type: CNotDealiased | CType, + name: $c.TypeId, + typeArgs: readonly $.CType[], + loc: $c.Loc, +): $.CTAliasRef => + Object.freeze({ + kind: "TypeAlias", + name, + type, + typeArgs, + loc, + }); +export type CTRef = $.CTRef; +export const CTRef = ( + name: $c.TypeId, + type: CTypeDeclRefable, + typeArgs: readonly $.CType[], + loc: $c.Loc, +): $.CTRef => + Object.freeze({ + kind: "type_ref", + name, + type, + typeArgs, + loc, + }); +export type CType = $.CType; +export type CTRecover = $.CTRecover; +export const CTRecover = (): $.CTRecover => + Object.freeze({ + kind: "recover", + }); + +export type CNotDealiased = $.CNotDealiased; +export const CNotDealiased = (): $.CNotDealiased => + Object.freeze({ + kind: "NotDealiased", + }); +export type CNotSet = $.CNotSet; +export const CNotSet = (): $.CNotSet => + Object.freeze({ + kind: "not-set", + }); diff --git a/src/next/ast/generated/checked.ts b/src/next/ast/generated/checked.ts new file mode 100644 index 0000000000..166325a3b9 --- /dev/null +++ b/src/next/ast/generated/checked.ts @@ -0,0 +1,401 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $c from "@/next/ast/common"; +import type * as $d from "@/next/ast/checked-type"; +import type * as $m from "@/next/ast/type-self"; +import type * as $v from "@/next/ast/via"; +import type * as $ from "@/next/ast/checked"; +import type { TactImport } from "@/next/imports/source"; +import type { Thunk } from "@/next/ast/lazy"; +import type { + AsmInstruction, + AsmShuffle, + ContractAttribute, +} from "@/next/ast/root"; +import type { CStmt } from "@/next/ast/checked-stmt"; +import type { Value } from "@/next/ast/value"; +import type { Effects } from "@/next/ast/effects"; + +export type CTypeParams = $.CTypeParams; +export const CTypeParams = ( + order: readonly $c.TypeId[], + set: ReadonlySet, +): CTypeParams => + Object.freeze({ + order, + set, + }); +export type CAlias = $.CAlias; +export const CAlias = ( + typeParams: $.CTypeParams, + type_: Thunk<$d.CType>, +): $.CAlias => + Object.freeze({ + kind: "alias", + typeParams, + type: type_, + }); + +export type CTFunction = $.CTFunction; +export const CTFunction = ( + typeParams: $.CTypeParams, + params: $.CParameters, + returnType: Thunk<$d.CType>, +): $.CTFunction => + Object.freeze({ + kind: "DecodedFnType", + typeParams, + params, + returnType, + }); +export type CBounce = $.CBounce; +export const CBounce = ( + message: readonly DeclMem[], + messageAny: DeclMem<$.CReceiverMessageAny> | undefined, +): $.CBounce => + Object.freeze({ + message, + messageAny, + }); + +export type CStruct = $.CStruct; +export const CStruct = ( + typeParams: $.CTypeParams, + fields: $c.Ordered<$.CField>, +): $.CStruct => + Object.freeze({ + kind: "struct", + typeParams, + fields, + }); +export type CUnion = $.CUnion; +export const CUnion = ( + typeParams: $.CTypeParams, + cases: ReadonlyMap>, +): $.CUnion => + Object.freeze({ + kind: "union", + typeParams, + cases, + }); +export type CTypeDecl = $.CTypeDecl; +export type CConstant = $.CConstant; +export const CConstant = ( + init: Thunk, + type_: Thunk<$d.CType>, +): $.CConstant => + Object.freeze({ + initializer: init, + type: type_, + }); +export type CExtension = $.CExtension; +export const CExtension = ( + type: $.CTMethod, + inline: boolean, + body: $.CBody, +): $.CExtension => + Object.freeze({ + type, + inline, + body, + }); +export type CSource = $.CSource; +export type Decl = $.Decl; +export const Decl = (decl: T, via: $v.ViaUser): Decl => ({ + decl, + via, +}); +export const CSource = ( + typeDecls: ReadonlyMap>, + fnSigs: ReadonlyMap>, + constSigs: ReadonlyMap>, + extSigs: ReadonlyMap[]>>, +): $.CSource => + Object.freeze({ + typeDecls, + functions: fnSigs, + constants: constSigs, + extensions: extSigs, + }); +export type CTMethod = $.CTMethod; +export const CTMethod = ( + mutates: boolean, + typeParams: $.CTypeParams, + self: $m.SelfType, + params: $.CParameters, + returnType: Thunk<$d.CType>, +): $.CTMethod => + Object.freeze({ + kind: "DecodedMethodType", + mutates, + typeParams, + self, + params, + returnType, + }); +export type CParameter = $.CParameter; +export const CParameter = ( + name: $c.OptionalId, + type_: Thunk<$d.CType>, + loc: $c.Loc, +): $.CParameter => + Object.freeze({ + name, + type: type_, + loc, + }); +export type SourceCheckResult = $.SourceCheckResult; +export const SourceCheckResult = ( + importedBy: TactImport, + globals: $.CSource, +): $.SourceCheckResult => + Object.freeze({ + importedBy, + globals, + }); +export type Recover = $.Recover; +export type CParameters = $.CParameters; +export const CParameters = ( + order: readonly $.CParameter[], + set: ReadonlySet, +): $.CParameters => + Object.freeze({ + order, + set, + }); +export type CTactBody = $.CTactBody; +export const CTactBody = ( + statements: Thunk, +): $.CTactBody => + Object.freeze({ + kind: "tact", + statements, + }); +export type CFuncBody = $.CFuncBody; +export const CFuncBody = (nativeName: $c.FuncId): $.CFuncBody => + Object.freeze({ + kind: "func", + nativeName, + }); +export type CFiftBody = $.CFiftBody; +export const CFiftBody = ( + shuffle: Thunk, + instructions: readonly AsmInstruction[], +): $.CFiftBody => + Object.freeze({ + kind: "fift", + shuffle, + instructions, + }); +export type CBody = $.CBody; +export type CFunction = $.CFunction; +export const CFunction = ( + type_: $.CTFunction, + inline: boolean, + body: $.CBody, +): $.CFunction => + Object.freeze({ + type: type_, + inline, + body, + }); +export type DeclMem = $.DeclMem; +export const DeclMem = (decl: T, via: $v.ViaMember): DeclMem => ({ + decl, + via, +}); +export type CField = $.CField; +export const CField = ( + type_: Thunk<$d.CType>, + init: Thunk | undefined, +): $.CField => + Object.freeze({ + kind: "field", + type: type_, + init, + }); +export type CFieldConstant = $.CFieldConstant; +export const CFieldConstant = ( + overridable: boolean, + type_: Thunk<$d.CType>, + init: Expr, +): $.CFieldConstant => + Object.freeze({ + kind: "constant", + overridable, + type: type_, + init, + }); +export type CFieldish = $.CFieldish; +export type CMethod = $.CMethod; +export const CMethod = ( + overridable: boolean, + type_: $.CTMethod, + inline: boolean, + body: Body, + getMethodId: Thunk | undefined, +): $.CMethod => + Object.freeze({ + overridable, + type: type_, + inline, + body, + getMethodId, + }); +export type CReceivers = $.CReceivers; +export type CMembers = $.CMembers; +export const CMembers = ( + fieldish: $c.Ordered<$.DeclMem<$.CFieldish>>, + methods: ReadonlyMap>>, + receivers: $.CReceivers, +): $.CMembers => + Object.freeze({ + fieldish, + methods, + receivers, + }); +export type CContractMembers = $.CContractMembers; +export type CTraitMembers = $.CTraitMembers; +export type CTrait = $.CTrait; +export const CTrait = ( + content: Thunk< + $.CMembers | undefined, $.CBody | undefined> + >, +): $.CTrait => + Object.freeze({ + kind: "trait", + content, + }); +export type CReceiverMessage = $.CReceiverMessage; +export const CReceiverMessage = ( + name: $c.OptionalId, + type_: $d.CTRef | $d.CTBounced, + statements: Thunk, +): $.CReceiverMessage => + Object.freeze({ + kind: "binary", + name, + type: type_, + statements, + }); +export type CReceiverMessageAny = $.CReceiverMessageAny; +export const CReceiverMessageAny = ( + name: $c.OptionalId, + statements: Thunk, +): $.CReceiverMessageAny => + Object.freeze({ + name, + statements, + }); +export type CReceiverString = $.CReceiverString; +export const CReceiverString = ( + comment: string, + statements: Thunk, +): $.CReceiverString => + Object.freeze({ + kind: "string", + comment, + statements, + }); +export type CReceiverStringAny = $.CReceiverStringAny; +export const CReceiverStringAny = ( + name: $c.OptionalId, + statements: Thunk, +): $.CReceiverStringAny => + Object.freeze({ + name, + statements, + }); +export type CReceiverEmpty = $.CReceiverEmpty; +export const CReceiverEmpty = ( + statements: Thunk, +): $.CReceiverEmpty => + Object.freeze({ + statements, + }); +export type CReceiverOpcode = $.CReceiverOpcode; +export type CReceiver = $.CReceiver; +export const CReceiver = ( + message: readonly DeclMem[], + messageAny: $.DeclMem<$.CReceiverMessageAny> | undefined, + stringAny: $.DeclMem<$.CReceiverStringAny> | undefined, + empty: $.DeclMem<$.CReceiverEmpty> | undefined, +): $.CReceiver => + Object.freeze({ + message, + messageAny, + stringAny, + empty, + }); +export type CMessage = $.CMessage; +export const CMessage = ( + opcode: Thunk, + fields: $c.Ordered<$.CField>, +): $.CMessage => + Object.freeze({ + kind: "message", + opcode, + fields, + }); +export type CInitEmpty = $.CInitEmpty; +export const CInitEmpty = ( + fill: Thunk>>, +): $.CInitEmpty => + Object.freeze({ + kind: "empty", + fill, + }); +export type CInitParam = $.CInitParam; +export const CInitParam = ( + type_: Thunk<$d.CType>, + init: Thunk | undefined, + loc: $c.Loc, +): $.CInitParam => + Object.freeze({ + type: type_, + init, + loc, + }); +export type CInitSimple = $.CInitSimple; +export const CInitSimple = ( + fill: $c.Ordered<$.CInitParam>, + loc: $c.Loc, +): $.CInitSimple => + Object.freeze({ + kind: "simple", + fill, + loc, + }); +export type CStatementsAux = $.CStatementsAux; +export const CStatementsAux = ( + body: readonly CStmt[], + effects: Effects, +): $.CStatementsAux => + Object.freeze({ + body, + effects, + }); +export type CInitFn = $.CInitFn; +export const CInitFn = ( + params: $.CParameters, + statements: Thunk, +): $.CInitFn => + Object.freeze({ + kind: "function", + params, + statements, + }); +export type CStatements = $.CStatements; +export type CInit = $.CInit; +export type CContract = $.CContract; +export type CTypeDeclRefable = $.CTypeDeclRefable; +export const CContract = ( + attributes: readonly ContractAttribute[], + init: $.CInit, + content: Thunk<$.CContractMembers>, +): $.CContract => + Object.freeze({ + kind: "contract", + attributes, + init, + content, + }); diff --git a/src/next/ast/generated/common.ts b/src/next/ast/generated/common.ts new file mode 100644 index 0000000000..390271866c --- /dev/null +++ b/src/next/ast/generated/common.ts @@ -0,0 +1,69 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $ from "@/next/ast/common"; +import { hideProperty } from "@/utils/tricks"; +export type Loc = $.Loc; +export type Builtin = $.Builtin; +export const Builtin = (): $.Builtin => + Object.freeze({ + kind: "builtin", + }); +export const isBuiltin = ($value: Builtin) => $value.kind === "builtin"; +export type Range = $.Range; +export const Range = ( + start: number, + end: number, + path: string, + code: string, +): $.Range => { + const result: $.Range = { + kind: "range", + start, + end, + path, + code, + }; + hideProperty(result, "code"); + hideProperty(result, "path"); + return Object.freeze(result); +}; +export type Id = $.Id; +export const Id = (text: string, loc: $.Loc): $.Id => + Object.freeze({ + kind: "id", + text, + loc, + }); +export const isId = ($value: Id) => $value.kind === "id"; +export type Wildcard = $.Wildcard; +export const Wildcard = (loc: $.Loc): $.Wildcard => + Object.freeze({ + kind: "wildcard", + loc, + }); +export const isWildcard = ($value: Wildcard) => $value.kind === "wildcard"; +export type OptionalId = $.OptionalId; +export type FuncId = $.FuncId; +export const FuncId = (text: string, loc: $.Loc): $.FuncId => + Object.freeze({ + kind: "func_id", + text, + loc, + }); +export const isFuncId = ($value: FuncId) => $value.kind === "func_id"; +export type TypeId = $.TypeId; +export const TypeId = (text: string, loc: $.Loc): $.TypeId => + Object.freeze({ + kind: "type_id", + text, + loc, + }); +export const isTypeId = ($value: TypeId) => $value.kind === "type_id"; +export type Ordered = $.Ordered; +export const Ordered = ( + order: readonly string[], + map: ReadonlyMap, +): $.Ordered => + Object.freeze({ + order, + map, + }); diff --git a/src/next/ast/generated/effects.ts b/src/next/ast/generated/effects.ts new file mode 100644 index 0000000000..8a4aa06a07 --- /dev/null +++ b/src/next/ast/generated/effects.ts @@ -0,0 +1,14 @@ +import type * as $ from "@/next/ast/effects"; + +export type Effects = $.Effects; +export const Effects = ( + mayRead: boolean, + mayWrite: boolean, + mustThrow: boolean, + mustSetSelf: ReadonlySet, +): $.Effects => Object.freeze({ + mayRead, + mayWrite, + mustThrow, + mustSetSelf, +}); diff --git a/src/next/ast/generated/expression.ts b/src/next/ast/generated/expression.ts new file mode 100644 index 0000000000..c8dd3b5a5b --- /dev/null +++ b/src/next/ast/generated/expression.ts @@ -0,0 +1,305 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $c from "@/next/ast/common"; +import type * as $t from "@/next/ast/type"; +import type * as $ from "@/next/ast/expression"; + +export type BinaryOperation = $.BinaryOperation; +export const allBinaryOperation: readonly $.BinaryOperation[] = [ + "+", + "-", + "*", + "/", + "!=", + ">", + "<", + ">=", + "<=", + "==", + "&&", + "||", + "%", + "<<", + ">>", + "&", + "|", + "^", +]; +export type UnaryOperation = $.UnaryOperation; +export const allUnaryOperation: readonly $.UnaryOperation[] = [ + "+", + "-", + "!", + "!!", + "~", +]; +export type CodeOf = $.CodeOf; +export const CodeOf = (contract: $c.TypeId, loc: $c.Loc): $.CodeOf => + Object.freeze({ + kind: "code_of", + contract, + loc, + }); +export const isCodeOf = ($value: CodeOf) => $value.kind === "code_of"; +export type NumberBase = $.NumberBase; +export const allNumberBase: readonly $.NumberBase[] = ["2", "8", "10", "16"]; +export type Number = $.Number; +export const Number = ( + base: $.NumberBase, + value: bigint, + loc: $c.Loc, +): $.Number => + Object.freeze({ + kind: "number", + base, + value, + loc, + }); +export const isNumber = ($value: Number) => $value.kind === "number"; +export type Boolean = $.Boolean; +export const Boolean = (value: boolean, loc: $c.Loc): $.Boolean => + Object.freeze({ + kind: "boolean", + value, + loc, + }); +export const isBoolean = ($value: Boolean) => $value.kind === "boolean"; +export type Null = $.Null; +export const Null = (loc: $c.Loc): $.Null => + Object.freeze({ + kind: "null", + loc, + }); +export const isNull = ($value: Null) => $value.kind === "null"; +export type String = $.String; +export const String = (value: string, loc: $c.Loc): $.String => + Object.freeze({ + kind: "string", + value, + loc, + }); +export const isString = ($value: String) => $value.kind === "string"; +export type Var = $.Var; +export const Var = (name: string, loc: $c.Loc): $.Var => + Object.freeze({ + kind: "var", + name, + loc, + }); +export const isVar = ($value: Var) => $value.kind === "var"; +export type Unit = $.Unit; +export const Unit = (loc: $c.Loc): $.Unit => + Object.freeze({ + kind: "unit", + loc, + }); +export const isUnit = ($value: Unit) => $value.kind === "unit"; +export type Tensor = $.Tensor; +export const Tensor = ( + children: readonly $.Expression[], + loc: $c.Loc, +): $.Tensor => + Object.freeze({ + kind: "tensor", + children, + loc, + }); +export const isTensor = ($value: Tensor) => $value.kind === "tensor"; +export type Tuple = $.Tuple; +export const Tuple = ( + children: readonly $.Expression[], + loc: $c.Loc, +): $.Tuple => + Object.freeze({ + kind: "tuple", + children, + loc, + }); +export const isTuple = ($value: Tuple) => $value.kind === "tuple"; +export type InitOf = $.InitOf; +export const InitOf = ( + contract: $c.TypeId, + args: readonly $.Expression[], + loc: $c.Loc, +): $.InitOf => + Object.freeze({ + kind: "init_of", + contract, + args, + loc, + }); +export const isInitOf = ($value: InitOf) => $value.kind === "init_of"; +export type StructFieldInitializer = $.StructFieldInitializer; +export const StructFieldInitializer = ( + field: $c.Id, + initializer: $.Expression, + loc: $c.Loc, +): $.StructFieldInitializer => + Object.freeze({ + kind: "struct_field_initializer", + field, + initializer, + loc, + }); +export const isStructFieldInitializer = ($value: StructFieldInitializer) => + $value.kind === "struct_field_initializer"; +export type StructInstance = $.StructInstance; +export const StructInstance = ( + type_: $c.TypeId, + typeArgs: readonly $t.Type[], + args: readonly $.StructFieldInitializer[], + loc: $c.Loc, +): $.StructInstance => + Object.freeze({ + kind: "struct_instance", + type: type_, + typeArgs, + args, + loc, + }); +export const isStructInstance = ($value: StructInstance) => + $value.kind === "struct_instance"; +export type StaticCall = $.StaticCall; +export const StaticCall = ( + function_: $c.Id, + typeArgs: readonly $t.Type[], + args: readonly $.Expression[], + loc: $c.Loc, +): $.StaticCall => + Object.freeze({ + kind: "static_call", + function: function_, + typeArgs, + args, + loc, + }); +export const isStaticCall = ($value: StaticCall) => + $value.kind === "static_call"; +export type FieldAccess = $.FieldAccess; +export const FieldAccess = ( + aggregate: $.Expression, + field: $c.Id, + loc: $c.Loc, +): $.FieldAccess => + Object.freeze({ + kind: "field_access", + aggregate, + field, + loc, + }); +export const isFieldAccess = ($value: FieldAccess) => + $value.kind === "field_access"; +export type MethodCall = $.MethodCall; +export const MethodCall = ( + self: $.Expression, + method: $c.Id, + typeArgs: readonly $t.Type[], + args: readonly $.Expression[], + loc: $c.Loc, +): $.MethodCall => + Object.freeze({ + kind: "method_call", + self, + method, + typeArgs, + args, + loc, + }); +export const isMethodCall = ($value: MethodCall) => + $value.kind === "method_call"; +export type Conditional = $.Conditional; +export const Conditional = ( + condition: $.Expression, + thenBranch: $.Expression, + elseBranch: $.Expression, + loc: $c.Loc, +): $.Conditional => + Object.freeze({ + kind: "conditional", + condition, + thenBranch, + elseBranch, + loc, + }); +export const isConditional = ($value: Conditional) => + $value.kind === "conditional"; +export type OpUnary = $.OpUnary; +export const OpUnary = ( + op: $.UnaryOperation, + operand: $.Expression, + loc: $c.Loc, +): $.OpUnary => + Object.freeze({ + kind: "op_unary", + op, + operand, + loc, + }); +export const isOpUnary = ($value: OpUnary) => $value.kind === "op_unary"; +export type OpBinary = $.OpBinary; +export const OpBinary = ( + op: $.BinaryOperation, + left: $.Expression, + right: $.Expression, + loc: $c.Loc, +): $.OpBinary => + Object.freeze({ + kind: "op_binary", + op, + left, + right, + loc, + }); +export const isOpBinary = ($value: OpBinary) => $value.kind === "op_binary"; +export type Expression = $.Expression; +export type MapField = $.MapField; +export const MapField = (key: $.Expression, value: $.Expression): $.MapField => + Object.freeze({ + key, + value, + }); +export type MapLiteral = $.MapLiteral; +export const MapLiteral = ( + type_: $t.TMap, + fields: readonly $.MapField[], + loc: $c.Loc, +): $.MapLiteral => + Object.freeze({ + kind: "map_literal", + type: type_, + fields, + loc, + }); +export const isMapLiteral = ($value: MapLiteral) => + $value.kind === "map_literal"; +export type SetLiteral = $.SetLiteral; +export const SetLiteral = ( + valueType: $t.Type, + fields: readonly $.Expression[], + loc: $c.Loc, +): $.SetLiteral => + Object.freeze({ + kind: "set_literal", + valueType, + fields, + loc, + }); +export const isSetLiteral = ($value: SetLiteral) => + $value.kind === "set_literal"; +export type StaticMethodCall = $.StaticMethodCall; +export const StaticMethodCall = ( + self: $c.TypeId, + typeArgs: readonly $t.Type[], + function_: $c.Id, + args: readonly $.Expression[], + loc: $c.Loc, +): $.StaticMethodCall => + Object.freeze({ + kind: "static_method_call", + self, + typeArgs, + function: function_, + args, + loc, + }); +export const isStaticMethodCall = ($value: StaticMethodCall) => + $value.kind === "static_method_call"; diff --git a/src/next/ast/generated/lowered-expr.ts b/src/next/ast/generated/lowered-expr.ts new file mode 100644 index 0000000000..857a2096dd --- /dev/null +++ b/src/next/ast/generated/lowered-expr.ts @@ -0,0 +1,222 @@ +import type * as $ from "@/next/ast/lowered-expr"; +import type * as $t from "@/next/ast/lowered-type"; +import type * as $c from "@/next/ast/common"; +import type { BinaryOperation, NumberBase, UnaryOperation } from "@/next/ast/expression"; +import type { SelfType } from "@/next/ast/type-self"; + +export type LTypeArgs = $.LTypeArgs; +export type LCodeOf = $.LCodeOf; +export const LCodeOf = (contract: $c.TypeId, computedType: $t.LType, loc: $c.Loc): $.LCodeOf => Object.freeze({ + kind: "code_of", + contract, + computedType, + loc +}); +export const isLCodeOf = ($value: LCodeOf) => $value.kind === "code_of"; +export type LNumber = $.LNumber; +export const LNumber = (base: NumberBase, value: bigint, computedType: $t.LTBasic, loc: $c.Loc): $.LNumber => Object.freeze({ + kind: "number", + base, + value, + computedType, + loc +}); +export const isLNumber = ($value: LNumber) => $value.kind === "number"; +export type LBoolean = $.LBoolean; +export const LBoolean = (value: boolean, computedType: $t.LTBasic, loc: $c.Loc): $.LBoolean => Object.freeze({ + kind: "boolean", + value, + computedType, + loc +}); +export const isLBoolean = ($value: LBoolean) => $value.kind === "boolean"; +export type LNull = $.LNull; +export const LNull = (computedType: $t.LTBasic, loc: $c.Loc): $.LNull => Object.freeze({ + kind: "null", + computedType, + loc +}); +export const isLNull = ($value: LNull) => $value.kind === "null"; +export type LString = $.LString; +export const LString = (value: string, computedType: $t.LTBasic, loc: $c.Loc): $.LString => Object.freeze({ + kind: "string", + value, + computedType, + loc +}); +export const isLString = ($value: LString) => $value.kind === "string"; +export type LVar = $.LVar; +export const LVar = (name: string, computedType: $t.LType, loc: $c.Loc): $.LVar => Object.freeze({ + kind: "var", + name, + computedType, + loc +}); +export const isLVar = ($value: LVar) => $value.kind === "var"; +export type LSelf = $.LSelf; +export const LSelf = (computedType: SelfType, loc: $c.Loc): $.LSelf => Object.freeze({ + kind: "self", + computedType, + loc +}); +export const isLSelf = ($value: LSelf) => $value.kind === "self"; +export type LUnit = $.LUnit; +export const LUnit = (computedType: $t.LTBasic, loc: $c.Loc): $.LUnit => Object.freeze({ + kind: "unit", + computedType, + loc +}); +export const isLUnit = ($value: LUnit) => $value.kind === "unit"; +export type LSetLiteral = $.LSetLiteral; +export const LSetLiteral = (valueType: $t.LType, fields: readonly $.LExpr[], computedType: $t.LType, loc: $c.Loc): $.LSetLiteral => Object.freeze({ + kind: "set_literal", + valueType, + fields, + computedType, + loc +}); +export const isLSetLiteral = ($value: LSetLiteral) => $value.kind === "set_literal"; +export type LMapField = $.LMapField; +export const LMapField = (key: $.LExpr, value: $.LExpr): $.LMapField => Object.freeze({ + key, + value +}); +export type LMapLiteral = $.LMapLiteral; +export const LMapLiteral = (fields: readonly $.LMapField[], computedType: $t.LTMap, loc: $c.Loc): $.LMapLiteral => Object.freeze({ + kind: "map_literal", + fields, + computedType, + loc +}); +export const isLMapLiteral = ($value: LMapLiteral) => $value.kind === "map_literal"; +export type LTensor = $.LTensor; +export const LTensor = (children: readonly $.LExpr[], computedType: $t.LTTensor, loc: $c.Loc): $.LTensor => Object.freeze({ + kind: "tensor", + children, + computedType, + loc +}); +export const isLTensor = ($value: LTensor) => $value.kind === "tensor"; +export type LTuple = $.LTuple; +export const LTuple = (children: readonly $.LExpr[], computedType: $t.LTTuple, loc: $c.Loc): $.LTuple => Object.freeze({ + kind: "tuple", + children, + computedType, + loc +}); +export const isLTuple = ($value: LTuple) => $value.kind === "tuple"; +export type LInitOf = $.LInitOf; +export const LInitOf = (contract: $c.TypeId, args: readonly $.LExpr[], computedType: $t.LType, loc: $c.Loc): $.LInitOf => Object.freeze({ + kind: "init_of", + contract, + args, + computedType, + loc +}); +export const isLInitOf = ($value: LInitOf) => $value.kind === "init_of"; +export type LStructCons = $.LStructCons; +export const LStructCons = (fields: $c.Ordered<$.LExpr>, computedType: $t.LTRef, loc: $c.Loc): $.LStructCons => Object.freeze({ + kind: "struct_instance", + fields, + computedType, + loc +}); +export const isLStructInstance = ($value: LStructCons) => $value.kind === "struct_instance"; +export type LFieldAccess = $.LFieldAccess; +export const LFieldAccess = (aggregate: $.LExpr, field: $c.Id, computedType: $t.LType, loc: $c.Loc): $.LFieldAccess => Object.freeze({ + kind: "field_access", + aggregate, + field, + computedType, + loc +}); +export const isLFieldAccess = ($value: LFieldAccess) => $value.kind === "field_access"; +export type LStaticMethodCall = $.LStaticMethodCall; +export const LStaticMethodCall = (self: $c.TypeId, typeArgs: $.LTypeArgs, function_: $c.Id, args: readonly $.LExpr[], computedType: $t.LType, loc: $c.Loc): $.LStaticMethodCall => Object.freeze({ + kind: "static_method_call", + self, + typeArgs, + function: function_, + args, + computedType, + loc +}); +export const isLStaticMethodCall = ($value: LStaticMethodCall) => $value.kind === "static_method_call"; +export type LStaticCall = $.LStaticCall; +export const LStaticCall = (function_: $c.Id, typeArgs: $.LTypeArgs, args: readonly $.LExpr[], computedType: $t.LType, loc: $c.Loc): $.LStaticCall => Object.freeze({ + kind: "static_call", + function: function_, + typeArgs, + args, + computedType, + loc +}); +export const isLStaticCall = ($value: LStaticCall) => $value.kind === "static_call"; +export type LMethodCall = $.LMethodCall; +export const LMethodCall = (self: $.LExpr, method: $c.Id, args: readonly $.LExpr[], typeArgs: $.LTypeArgs, computedType: $t.LType, loc: $c.Loc): $.LMethodCall => Object.freeze({ + kind: "method_call", + self, + method, + args, + typeArgs, + computedType, + loc +}); +export const isLMethodCall = ($value: LMethodCall) => $value.kind === "method_call"; +export type LConditional = $.LConditional; +export const LConditional = (condition: $.LExpr, thenBranch: $.LExpr, elseBranch: $.LExpr, computedType: $t.LType, loc: $c.Loc): $.LConditional => Object.freeze({ + kind: "conditional", + condition, + thenBranch, + elseBranch, + computedType, + loc +}); +export const isLConditional = ($value: LConditional) => $value.kind === "conditional"; +export type LOpUnary = $.LOpUnary; +export const LOpUnary = (op: UnaryOperation, operand: $.LExpr, typeArgs: $.LTypeArgs, computedType: $t.LType, loc: $c.Loc): $.LOpUnary => Object.freeze({ + kind: "op_unary", + op, + operand, + typeArgs, + computedType, + loc +}); +export const isLOpUnary = ($value: LOpUnary) => $value.kind === "op_unary"; +export type LOpBinary = $.LOpBinary; +export const LOpBinary = (op: BinaryOperation, left: $.LExpr, right: $.LExpr, typeArgs: $.LTypeArgs, computedType: $t.LType, loc: $c.Loc): $.LOpBinary => Object.freeze({ + kind: "op_binary", + op, + left, + right, + typeArgs, + computedType, + loc +}); +export const isLOpBinary = ($value: LOpBinary) => $value.kind === "op_binary"; +export type LExpr = $.LExpr; +export type LLVar = $.LLVar; +export const LLVar = (name: string, computedType: $t.LType, loc: $c.Loc): $.LLVar => Object.freeze({ + kind: "var", + name, + computedType, + loc +}); +export const isLLVar = ($value: LLVar) => $value.kind === "var"; +export type LLSelf = $.LLSelf; +export const LLSelf = (computedType: SelfType, loc: $c.Loc): $.LLSelf => Object.freeze({ + kind: "self", + computedType, + loc +}); +export const isLLSelf = ($value: LLSelf) => $value.kind === "self"; +export type LLFieldAccess = $.LLFieldAccess; +export const LLFieldAccess = (aggregate: $.LLValue, field: $c.Id, computedType: $t.LType, loc: $c.Loc): $.LLFieldAccess => Object.freeze({ + kind: "field_access", + aggregate, + field, + computedType, + loc +}); +export const isLLFieldAccess = ($value: LLFieldAccess) => $value.kind === "field_access"; +export type LLValue = $.LLValue; \ No newline at end of file diff --git a/src/next/ast/generated/lowered-stmt.ts b/src/next/ast/generated/lowered-stmt.ts new file mode 100644 index 0000000000..37edebb167 --- /dev/null +++ b/src/next/ast/generated/lowered-stmt.ts @@ -0,0 +1,124 @@ +import type * as $ from "@/next/ast/lowered-stmt"; +import type * as $e from "@/next/ast/lowered-expr"; +import type * as $c from "@/next/ast/common"; +import type { AugmentedAssignOperation } from "@/next/ast/statement"; + +export type LStmtLet = $.LStmtLet; +export const LStmtLet = (name: $c.OptionalId, expression: $e.LExpr, loc: $c.Loc): $.LStmtLet => Object.freeze({ + kind: "let", + name, + expression, + loc +}); +export const isLStmtLet = ($value: LStmtLet) => $value.kind === "let"; +export type LStmtReturn = $.LStmtReturn; +export const LStmtReturn = (expression: $e.LExpr | undefined, loc: $c.Loc): $.LStmtReturn => Object.freeze({ + kind: "return", + expression, + loc +}); +export const isLStmtReturn = ($value: LStmtReturn) => $value.kind === "return"; +export type LStmtExpression = $.LStmtExpression; +export const LStmtExpression = (expression: $e.LExpr, loc: $c.Loc): $.LStmtExpression => Object.freeze({ + kind: "expression", + expression, + loc +}); +export const isLStmtExpression = ($value: LStmtExpression) => $value.kind === "expression"; +export type LStmtAssign = $.LStmtAssign; +export const LStmtAssign = (path: $e.LLValue, expression: $e.LExpr, loc: $c.Loc): $.LStmtAssign => Object.freeze({ + kind: "assign", + path, + expression, + loc +}); +export const isLStmtAssign = ($value: LStmtAssign) => $value.kind === "assign"; +export type LStmtAugmentedAssign = $.LStmtAugmentedAssign; +export const LStmtAugmentedAssign = (op: AugmentedAssignOperation, path: $e.LLValue, expression: $e.LExpr, loc: $c.Loc): $.LStmtAugmentedAssign => Object.freeze({ + kind: "augmentedassign", + op, + path, + expression, + loc +}); +export const isLStmtAugmentedAssign = ($value: LStmtAugmentedAssign) => $value.kind === "augmentedassign"; +export type LDestructPattern = $.LDestructPattern; +export const LDestructPattern = (field: $c.Id, variable: $c.OptionalId): $.LDestructPattern => Object.freeze({ + field, + variable +}); +export type LStmtDestruct = $.LStmtDestruct; +export const LStmtDestruct = (type_: $c.TypeId, identifiers: $c.Ordered<$.LDestructPattern>, ignoreUnspecifiedFields: boolean, expression: $e.LExpr, loc: $c.Loc): $.LStmtDestruct => Object.freeze({ + kind: "destruct", + type: type_, + identifiers, + ignoreUnspecifiedFields, + expression, + loc +}); +export const isLStmtDestruct = ($value: LStmtDestruct) => $value.kind === "destruct"; +export type LStmtBlock = $.LStmtBlock; +export const LStmtBlock = (statements: $.LStmtList, loc: $c.Loc): $.LStmtBlock => Object.freeze({ + kind: "block", + statements, + loc +}); +export const isLStmtBlock = ($value: LStmtBlock) => $value.kind === "block"; +export type LStmtForEach = $.LStmtForEach; +export const LStmtForEach = (keyName: $c.OptionalId, valueName: $c.OptionalId, map: $e.LExpr, statements: $.LStmtList, loc: $c.Loc): $.LStmtForEach => Object.freeze({ + kind: "foreach", + keyName, + valueName, + map, + statements, + loc +}); +export const isLStmtForEach = ($value: LStmtForEach) => $value.kind === "foreach"; +export type LCatchBlock = $.LCatchBlock; +export const LCatchBlock = (name: $c.OptionalId, statements: $.LStmtList): $.LCatchBlock => Object.freeze({ + name, + statements +}); +export type LStmtTry = $.LStmtTry; +export const LStmtTry = (statements: $.LStmtList, catchBlock: $.LCatchBlock | undefined, loc: $c.Loc): $.LStmtTry => Object.freeze({ + kind: "try", + statements, + catchBlock, + loc +}); +export const isLStmtTry = ($value: LStmtTry) => $value.kind === "try"; +export type LStmtRepeat = $.LStmtRepeat; +export const LStmtRepeat = (iterations: $e.LExpr, statements: $.LStmtList, loc: $c.Loc): $.LStmtRepeat => Object.freeze({ + kind: "repeat", + iterations, + statements, + loc +}); +export const isLStmtRepeat = ($value: LStmtRepeat) => $value.kind === "repeat"; +export type LStmtUntil = $.LStmtUntil; +export const LStmtUntil = (condition: $e.LExpr, statements: $.LStmtList, loc: $c.Loc): $.LStmtUntil => Object.freeze({ + kind: "until", + condition, + statements, + loc +}); +export const isLStmtUntil = ($value: LStmtUntil) => $value.kind === "until"; +export type LStmtWhile = $.LStmtWhile; +export const LStmtWhile = (condition: $e.LExpr, statements: $.LStmtList, loc: $c.Loc): $.LStmtWhile => Object.freeze({ + kind: "while", + condition, + statements, + loc +}); +export const isLStmtWhile = ($value: LStmtWhile) => $value.kind === "while"; +export type LStmtList = $.LStmtList; +export type LStmtCondition = $.LStmtCondition; +export const LStmtCondition = (condition: $e.LExpr, trueStatements: $.LStmtList, falseStatements: $.LStmtList | undefined, loc: $c.Loc): $.LStmtCondition => Object.freeze({ + kind: "condition", + condition, + trueStatements, + falseStatements, + loc +}); +export const isLStmtCondition = ($value: LStmtCondition) => $value.kind === "condition"; +export type LStmt = $.LStmt; \ No newline at end of file diff --git a/src/next/ast/generated/lowered-type.ts b/src/next/ast/generated/lowered-type.ts new file mode 100644 index 0000000000..f38c821e78 --- /dev/null +++ b/src/next/ast/generated/lowered-type.ts @@ -0,0 +1,74 @@ +import type * as $ from "@/next/ast/lowered-type"; +import type * as $c from "@/next/ast/common"; +import type { BasicType } from "@/next/ast/type-basic"; +import type { CTypeDeclRefable } from "@/next/ast/checked"; + +export type LTParamRef = $.LTParamRef; +export const LTParamRef = (name: $c.TypeId, loc: $c.Loc): $.LTParamRef => Object.freeze({ + kind: "TypeParam", + name, + loc +}); +export const isLTParamRef = ($value: LTParamRef) => $value.kind === "TypeParam"; +export type LTBounced = $.LTBounced; +export const LTBounced = (name: $c.TypeId, loc: $c.Loc): $.LTBounced => Object.freeze({ + kind: "TypeBounced", + name, + loc +}); +export const isLTBounced = ($value: LTBounced) => $value.kind === "TypeBounced"; +export type LTBasic = $.LTBasic; +export const LTBasic = (type_: BasicType, loc: $c.Loc): $.LTBasic => Object.freeze({ + kind: "basic", + type: type_, + loc +}); +export const isLTBasic = ($value: LTBasic) => $value.kind === "basic"; +export type LTTensor = $.LTTensor; +export const LTTensor = (typeArgs: readonly $.LType[], loc: $c.Loc): $.LTTensor => Object.freeze({ + kind: "tensor_type", + typeArgs, + loc +}); +export const isLTTensor = ($value: LTTensor) => $value.kind === "tensor_type"; +export type LTTuple = $.LTTuple; +export const LTTuple = (typeArgs: readonly $.LType[], loc: $c.Loc): $.LTTuple => Object.freeze({ + kind: "tuple_type", + typeArgs, + loc +}); +export const isLTTuple = ($value: LTTuple) => $value.kind === "tuple_type"; +export type LTMaybe = $.LTMaybe; +export const LTMaybe = (type_: $.LType, loc: $c.Loc): $.LTMaybe => Object.freeze({ + kind: "TypeMaybe", + type: type_, + loc +}); +export const isLTMaybe = ($value: LTMaybe) => $value.kind === "TypeMaybe"; +export type LTMap = $.LTMap; +export const LTMap = (key: $.LType, value: $.LType, loc: $c.Loc): $.LTMap => Object.freeze({ + kind: "map_type", + key, + value, + loc +}); +export const isLTMap = ($value: LTMap) => $value.kind === "map_type"; +export type LTAliasRef = $.LTAliasRef; +export const LTAliasRef = (name: $c.TypeId, type_: $.LType, typeArgs: readonly $.LType[], loc: $c.Loc): $.LTAliasRef => Object.freeze({ + kind: "TypeAlias", + name, + type: type_, + typeArgs, + loc +}); +export const isLTAliasRef = ($value: LTAliasRef) => $value.kind === "TypeAlias"; +export type LTRef = $.LTRef; +export const LTRef = (name: $c.TypeId, type_: CTypeDeclRefable, typeArgs: readonly $.LType[], loc: $c.Loc): $.LTRef => Object.freeze({ + kind: "type_ref", + name, + type: type_, + typeArgs, + loc +}); +export const isLTRef = ($value: LTRef) => $value.kind === "type_ref"; +export type LType = $.LType; \ No newline at end of file diff --git a/src/next/ast/generated/lowered.ts b/src/next/ast/generated/lowered.ts new file mode 100644 index 0000000000..4494205084 --- /dev/null +++ b/src/next/ast/generated/lowered.ts @@ -0,0 +1,237 @@ +import type * as $ from "@/next/ast/lowered"; +import type * as $c from "@/next/ast/common"; +import type * as $d from "@/next/ast/lowered-type"; +import type * as $v from "@/next/ast/value"; +import type * as $s from "@/next/ast/lowered-stmt"; +import type { Effects } from "@/next/ast/effects"; +import type { SelfType } from "@/next/ast/type-self"; +import type { AsmInstruction } from "@/next/ast/root"; +import type { AsmShuffle, ContractAttribute } from "@/next/ast/root"; + +export type LTypeParams = $.LTypeParams; +export const LTypeParams = (order: readonly $c.TypeId[], set: ReadonlySet): $.LTypeParams => Object.freeze({ + order, + set +}); +export type LAlias = $.LAlias; +export const LAlias = (typeParams: $.LTypeParams, type_: $d.LType): $.LAlias => Object.freeze({ + kind: "alias", + typeParams, + type: type_ +}); +export const isLAlias = ($value: LAlias) => $value.kind === "alias"; +export type LInitEmpty = $.LInitEmpty; +export const LInitEmpty = (fill: $c.Ordered<$v.Value>): $.LInitEmpty => Object.freeze({ + kind: "empty", + fill +}); +export const isLInitEmpty = ($value: LInitEmpty) => $value.kind === "empty"; +export type LInitParam = $.LInitParam; +export const LInitParam = (type_: $d.LType, init: $v.Value | undefined, loc: $c.Loc): $.LInitParam => Object.freeze({ + type: type_, + init, + loc +}); +export type LInitSimple = $.LInitSimple; +export const LInitSimple = (fill: $c.Ordered<$.LInitParam>, loc: $c.Loc): $.LInitSimple => Object.freeze({ + kind: "simple", + fill, + loc +}); +export const isLInitSimple = ($value: LInitSimple) => $value.kind === "simple"; +export type LParameter = $.LParameter; +export const LParameter = (name: $c.OptionalId, type_: $d.LType, loc: $c.Loc): $.LParameter => Object.freeze({ + name, + type: type_, + loc +}); +export type LParameters = $.LParameters; +export const LParameters = (order: readonly $.LParameter[], set: ReadonlySet): $.LParameters => Object.freeze({ + order, + set +}); +export type LStatements = $.LStatements; +export const LStatements = (body: readonly $s.LStmt[], effects: Effects): $.LStatements => Object.freeze({ + body, + effects +}); +export type LInitFn = $.LInitFn; +export const LInitFn = (params: $.LParameters, statements: $.LStatements): $.LInitFn => Object.freeze({ + kind: "function", + params, + statements +}); +export const isLInitFn = ($value: LInitFn) => $value.kind === "function"; +export type LInit = $.LInit; +export type LField = $.LField; +export const LField = (type_: $d.LType, init: $v.Value | undefined): $.LField => Object.freeze({ + kind: "field", + type: type_, + init +}); +export const isLField = ($value: LField) => $value.kind === "field"; +export type LFieldConstant = $.LFieldConstant; +export const LFieldConstant = (type_: $d.LType, init: Expr): $.LFieldConstant => Object.freeze({ + kind: "constant", + type: type_, + init +}); +export const isLFieldConstant = ($value: LFieldConstant) => $value.kind === "constant"; +export type LFieldish = $.LFieldish; +export type LTMethod = $.LTMethod; +export const LTMethod = (mutates: boolean, typeParams: $.LTypeParams, self: SelfType, params: $.LParameters, returnType: $d.LType): $.LTMethod => Object.freeze({ + kind: "DecodedMethodType", + mutates, + typeParams, + self, + params, + returnType +}); +export const isLTMethod = ($value: LTMethod) => $value.kind === "DecodedMethodType"; +export type LMethod = $.LMethod; +export const LMethod = (type_: $.LTMethod, inline: boolean, body: Body, getMethodId: bigint | undefined): $.LMethod => Object.freeze({ + type: type_, + inline, + body, + getMethodId +}); +export type LReceiverMessage = $.LReceiverMessage; +export const LReceiverMessage = (name: $c.OptionalId, type_: $d.LTBounced | $d.LTRef, statements: $.LStatements): $.LReceiverMessage => Object.freeze({ + kind: "binary", + name, + type: type_, + statements +}); +export const isLReceiverMessage = ($value: LReceiverMessage) => $value.kind === "binary"; +export type LReceiverAny = $.LReceiverAny; +export const LReceiverAny = (name: $c.OptionalId, statements: $.LStatements): $.LReceiverAny => Object.freeze({ + name, + statements +}); +export type LBounce = $.LBounce; +export const LBounce = (message: readonly $.LReceiverMessage[], messageAny: $.LReceiverAny | undefined): $.LBounce => Object.freeze({ + message, + messageAny +}); +export type LReceiverString = $.LReceiverString; +export const LReceiverString = (comment: string, statements: $.LStatements): $.LReceiverString => Object.freeze({ + kind: "string", + comment, + statements +}); +export const isLReceiverString = ($value: LReceiverString) => $value.kind === "string"; +export type LReceiverOpcode = $.LReceiverOpcode; +export type LReceiverEmpty = $.LReceiverEmpty; +export const LReceiverEmpty = (statements: $.LStatements): $.LReceiverEmpty => Object.freeze({ + statements +}); +export type LReceiver = $.LReceiver; +export const LReceiver = (message: readonly $.LReceiverOpcode[], messageAny: $.LReceiverAny | undefined, stringAny: $.LReceiverAny | undefined, empty: $.LReceiverEmpty | undefined): $.LReceiver => Object.freeze({ + message, + messageAny, + stringAny, + empty +}); +export type LReceivers = $.LReceivers; +export const LReceivers = (bounce: $.LBounce, internal: $.LReceiver, external: $.LReceiver): $.LReceivers => Object.freeze({ + bounce, + internal, + external +}); +export type LMembers = $.LMembers; +export const LMembers = (fieldish: $c.Ordered<$.LFieldish>, methods: ReadonlyMap>, receivers: $.LReceivers): $.LMembers => Object.freeze({ + fieldish, + methods, + receivers +}); +export type LTactBody = $.LTactBody; +export const LTactBody = (statements: $.LStatements): $.LTactBody => Object.freeze({ + kind: "tact", + statements +}); +export const isLTactBody = ($value: LTactBody) => $value.kind === "tact"; +export type LFuncBody = $.LFuncBody; +export const LFuncBody = (nativeName: $c.FuncId): $.LFuncBody => Object.freeze({ + kind: "func", + nativeName +}); +export const isLFuncBody = ($value: LFuncBody) => $value.kind === "func"; +export type LFiftBody = $.LFiftBody; +export const LFiftBody = (shuffle: AsmShuffle, instructions: readonly AsmInstruction[]): $.LFiftBody => Object.freeze({ + kind: "fift", + shuffle, + instructions +}); +export const isLFiftBody = ($value: LFiftBody) => $value.kind === "fift"; +export type LBody = $.LBody; +export type LContractMembers = $.LContractMembers; +export type LContract = $.LContract; +export const LContract = (attributes: readonly ContractAttribute[], init: $.LInit, content: $.LContractMembers): $.LContract => Object.freeze({ + kind: "contract", + attributes, + init, + content +}); +export const isLContract = ($value: LContract) => $value.kind === "contract"; +export type LTraitMembers = $.LTraitMembers; +export type LTrait = $.LTrait; +export const LTrait = (content: $.LTraitMembers): $.LTrait => Object.freeze({ + kind: "trait", + content +}); +export const isLTrait = ($value: LTrait) => $value.kind === "trait"; +export type LStruct = $.LStruct; +export const LStruct = (typeParams: $.LTypeParams, fields: $c.Ordered<$.LField>): $.LStruct => Object.freeze({ + kind: "struct", + typeParams, + fields +}); +export const isLStruct = ($value: LStruct) => $value.kind === "struct"; +export type LMessage = $.LMessage; +export const LMessage = (opcode: bigint, fields: $c.Ordered<$.LField>): $.LMessage => Object.freeze({ + kind: "message", + opcode, + fields +}); +export const isLMessage = ($value: LMessage) => $value.kind === "message"; +export type LUnion = $.LUnion; +export const LUnion = (typeParams: $.LTypeParams, cases: ReadonlyMap>): $.LUnion => Object.freeze({ + kind: "union", + typeParams, + cases +}); +export const isLUnion = ($value: LUnion) => $value.kind === "union"; +export type LTypeDecl = $.LTypeDecl; +export type LTFunction = $.LTFunction; +export const LTFunction = (typeParams: $.LTypeParams, params: $.LParameters, returnType: $d.LType): $.LTFunction => Object.freeze({ + kind: "DecodedFnType", + typeParams, + params, + returnType +}); +export const isLTFunction = ($value: LTFunction) => $value.kind === "DecodedFnType"; +export type LFunction = $.LFunction; +export const LFunction = (type_: $.LTFunction, inline: boolean, body: $.LBody): $.LFunction => Object.freeze({ + type: type_, + inline, + body +}); +export type LConstant = $.LConstant; +export const LConstant = (initializer: $v.Value, type_: $d.LType): $.LConstant => Object.freeze({ + initializer, + type: type_ +}); +export type LExtension = $.LExtension; +export const LExtension = (type_: $.LTMethod, inline: boolean, body: $.LBody): $.LExtension => Object.freeze({ + type: type_, + inline, + body +}); +export type LSource = $.LSource; +export const LSource = (typeDecls: ReadonlyMap, functions: ReadonlyMap, constants: ReadonlyMap, extensions: ReadonlyMap): $.LSource => Object.freeze({ + typeDecls, + functions, + constants, + extensions +}); +export type LTypeDeclRefable = $.LTypeDeclRefable; diff --git a/src/next/ast/generated/root.ts b/src/next/ast/generated/root.ts new file mode 100644 index 0000000000..41a20f641c --- /dev/null +++ b/src/next/ast/generated/root.ts @@ -0,0 +1,461 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $c from "@/next/ast/common"; +import type * as $e from "@/next/ast/expression"; +import type * as $s from "@/next/ast/statement"; +import type * as $t from "@/next/ast/type"; +import type * as $f from "@/next/fs"; +import type * as $ from "@/next/ast/root"; +export type ImportType = $.ImportType; +export const allImportType: readonly $.ImportType[] = ["stdlib", "relative"]; +export type ImportPath = $.ImportPath; +export const ImportPath = ( + path: $f.RelativePath, + type_: $.ImportType, + language: $c.Language, +): $.ImportPath => + Object.freeze({ + path, + type: type_, + language, + }); +export type Import = $.Import; +export const Import = (importPath: $.ImportPath, loc: $c.Loc): $.Import => + Object.freeze({ + kind: "import", + importPath, + loc, + }); +export const isImport = ($value: Import) => $value.kind === "import"; +export type RegularBody = $.RegularBody; +export const RegularBody = ( + statements: readonly $s.Statement[], +): $.RegularBody => + Object.freeze({ + kind: "regular_body", + statements, + }); +export const isRegularBody = ($value: RegularBody) => + $value.kind === "regular_body"; +export type AsmShuffle = $.AsmShuffle; +export const AsmShuffle = ( + args: readonly $c.Id[], + ret: readonly $e.Number[], +): $.AsmShuffle => + Object.freeze({ + args, + ret, + }); +export type AsmInstruction = $.AsmInstruction; +export type AsmBody = $.AsmBody; +export const AsmBody = ( + shuffle: $.AsmShuffle, + instructions: readonly $.AsmInstruction[], +): $.AsmBody => + Object.freeze({ + kind: "asm_body", + shuffle, + instructions, + }); +export const isAsmBody = ($value: AsmBody) => $value.kind === "asm_body"; +export type NativeBody = $.NativeBody; +export const NativeBody = (nativeName: $c.FuncId): $.NativeBody => + Object.freeze({ + kind: "native_body", + nativeName, + }); +export const isNativeBody = ($value: NativeBody) => + $value.kind === "native_body"; +export type AbstractBody = $.AbstractBody; +export const AbstractBody = (): $.AbstractBody => + Object.freeze({ + kind: "abstract_body", + }); +export const isAbstractBody = ($value: AbstractBody) => + $value.kind === "abstract_body"; +export type FunctionalBody = $.FunctionalBody; +export type Function = $.Function; +export const Function = ( + inline: boolean, + name: $c.Id, + type_: $t.TFunction, + body: $.FunctionalBody, + loc: $c.Loc, +): $.Function => + Object.freeze({ + kind: "function", + inline, + name, + type: type_, + body, + loc, + }); +export const isFunction = ($value: Function) => $value.kind === "function"; +export type ConstantDef = $.ConstantDef; +export const ConstantDef = ( + type_: $t.Type | undefined, + initializer: $e.Expression, +): $.ConstantDef => + Object.freeze({ + kind: "constant_def", + type: type_, + initializer, + }); +export const isConstantDef = ($value: ConstantDef) => + $value.kind === "constant_def"; +export type ConstantDecl = $.ConstantDecl; +export const ConstantDecl = (type_: $t.Type): $.ConstantDecl => + Object.freeze({ + kind: "constant_decl", + type: type_, + }); +export const isConstantDecl = ($value: ConstantDecl) => + $value.kind === "constant_decl"; +export type ConstantInit = $.ConstantInit; +export type Constant = $.Constant; +export const Constant = ( + name: $c.Id, + init: $.ConstantInit, + loc: $c.Loc, +): $.Constant => + Object.freeze({ + kind: "constant", + name, + init, + loc, + }); +export const isConstant = ($value: Constant) => $value.kind === "constant"; +export type Extension = $.Extension; +export const Extension = ( + mutates: boolean, + fun: $.Function, + selfType: $t.Type, +): $.Extension => + Object.freeze({ + kind: "extension", + mutates, + fun, + selfType, + }); +export const isExtension = ($value: Extension) => $value.kind === "extension"; +export type FieldDecl = $.FieldDecl; +export const FieldDecl = ( + name: $c.Id, + type_: $t.Type, + initializer: $e.Expression | undefined, + loc: $c.Loc, +): $.FieldDecl => + Object.freeze({ + kind: "field_decl", + name, + type: type_, + initializer, + loc, + }); +export const isFieldDecl = ($value: FieldDecl) => $value.kind === "field_decl"; +export type StructDecl = $.StructDecl; +export const StructDecl = ( + name: $c.TypeId, + typeParams: readonly $c.TypeId[], + fields: readonly $.FieldDecl[], + loc: $c.Loc, +): $.StructDecl => + Object.freeze({ + kind: "struct_decl", + name, + typeParams, + fields, + loc, + }); +export const isStructDecl = ($value: StructDecl) => + $value.kind === "struct_decl"; +export type MessageDecl = $.MessageDecl; +export const MessageDecl = ( + name: $c.TypeId, + opcode: $e.Expression | undefined, + fields: readonly $.FieldDecl[], + loc: $c.Loc, +): $.MessageDecl => + Object.freeze({ + kind: "message_decl", + name, + opcode, + fields, + loc, + }); +export const isMessageDecl = ($value: MessageDecl) => + $value.kind === "message_decl"; +export type UnionCase = $.UnionCase; +export const UnionCase = ( + name: $c.TypeId, + fields: readonly $.FieldDecl[], +): $.UnionCase => + Object.freeze({ + name, + fields, + }); +export type UnionDecl = $.UnionDecl; +export const UnionDecl = ( + name: $c.TypeId, + typeParams: readonly $c.TypeId[], + cases: readonly $.UnionCase[], + loc: $c.Loc, +): $.UnionDecl => + Object.freeze({ + kind: "union_decl", + name, + typeParams, + cases, + loc, + }); +export const isUnionDecl = ($value: UnionDecl) => $value.kind === "union_decl"; +export type AliasDecl = $.AliasDecl; +export const AliasDecl = ( + name: $c.TypeId, + typeParams: readonly $c.TypeId[], + type_: $t.Type, + loc: $c.Loc, +): $.AliasDecl => + Object.freeze({ + kind: "alias_decl", + name, + typeParams, + type: type_, + loc, + }); +export const isAliasDecl = ($value: AliasDecl) => $value.kind === "alias_decl"; +export type InitFunction = $.InitFunction; +export const InitFunction = ( + params: readonly $t.TypedParameter[], + statements: readonly $s.Statement[], + loc: $c.Loc, +): $.InitFunction => + Object.freeze({ + kind: "init_function", + params, + statements, + loc, + }); +export const isInitFunction = ($value: InitFunction) => + $value.kind === "init_function"; +export type InitParams = $.InitParams; +export const InitParams = ( + params: readonly $.FieldDecl[], + loc: $c.Loc, +): $.InitParams => + Object.freeze({ + kind: "init_params", + params, + loc, + }); +export const isInitParams = ($value: InitParams) => + $value.kind === "init_params"; +export type Init = $.Init; +export type ContractAttribute = $.ContractAttribute; +export const ContractAttribute = ( + name: string, + loc: $c.Loc, +): $.ContractAttribute => + Object.freeze({ + type: "interface", + name, + loc, + }); +export type GetAttribute = $.GetAttribute; +export const GetAttribute = ( + methodId: $e.Expression | undefined, + loc: $c.Loc, +): $.GetAttribute => + Object.freeze({ + methodId, + loc, + }); +export type Method = $.Method; +export const Method = ( + mutates: boolean, + overridable: boolean, + override: boolean, + get: $.GetAttribute | undefined, + fun: $.Function, +): $.Method => + Object.freeze({ + kind: "method", + mutates, + overridable, + override, + get, + fun, + }); +export const isMethod = ($value: Method) => $value.kind === "method"; +export type ReceiverSimple = $.ReceiverSimple; +export const ReceiverSimple = (param: $t.TypedParameter): $.ReceiverSimple => + Object.freeze({ + kind: "simple", + param, + }); +export const isReceiverSimple = ($value: ReceiverSimple) => + $value.kind === "simple"; +export type ReceiverFallback = $.ReceiverFallback; +export const ReceiverFallback = (): $.ReceiverFallback => + Object.freeze({ + kind: "fallback", + }); +export const isReceiverFallback = ($value: ReceiverFallback) => + $value.kind === "fallback"; +export type ReceiverComment = $.ReceiverComment; +export const ReceiverComment = (comment: $e.String): $.ReceiverComment => + Object.freeze({ + kind: "comment", + comment, + }); +export const isReceiverComment = ($value: ReceiverComment) => + $value.kind === "comment"; +export type ReceiverSubKind = $.ReceiverSubKind; +export type ReceiverInternal = $.ReceiverInternal; +export const ReceiverInternal = ( + subKind: $.ReceiverSubKind, + loc: $c.Loc, +): $.ReceiverInternal => + Object.freeze({ + kind: "internal", + subKind, + loc, + }); +export const isReceiverInternal = ($value: ReceiverInternal) => + $value.kind === "internal"; +export type ReceiverExternal = $.ReceiverExternal; +export const ReceiverExternal = ( + subKind: $.ReceiverSubKind, + loc: $c.Loc, +): $.ReceiverExternal => + Object.freeze({ + kind: "external", + subKind, + loc, + }); +export const isReceiverExternal = ($value: ReceiverExternal) => + $value.kind === "external"; +export type ReceiverBounce = $.ReceiverBounce; +export const ReceiverBounce = ( + param: $t.TypedParameter, + loc: $c.Loc, +): $.ReceiverBounce => + Object.freeze({ + kind: "bounce", + param, + loc, + }); +export const isReceiverBounce = ($value: ReceiverBounce) => + $value.kind === "bounce"; +export type ReceiverKind = $.ReceiverKind; +export type Receiver = $.Receiver; +export const Receiver = ( + selector: $.ReceiverKind, + statements: readonly $s.Statement[], + loc: $c.Loc, +): $.Receiver => + Object.freeze({ + kind: "receiver", + selector, + statements, + loc, + }); +export const isReceiver = ($value: Receiver) => $value.kind === "receiver"; +export type FieldConstant = $.FieldConstant; +export const FieldConstant = ( + overridable: boolean, + override: boolean, + body: $.Constant, +): $.FieldConstant => + Object.freeze({ + kind: "field_const", + overridable, + override, + body, + }); +export const isFieldConstant = ($value: FieldConstant) => + $value.kind === "field_const"; +export type LocalItems = $.LocalItems; +export const LocalItems = ( + fields: readonly $.FieldDecl[], + methods: readonly $.Method[], + receivers: readonly $.Receiver[], + constants: readonly $.FieldConstant[], +): $.LocalItems => + Object.freeze({ + fields, + methods, + receivers, + constants, + }); +export type Contract = $.Contract; +export const Contract = ( + init: $.Init | undefined, + name: $c.TypeId, + traits: readonly $c.TypeId[], + attributes: readonly $.ContractAttribute[], + declarations: $.LocalItems, + loc: $c.Loc, +): $.Contract => + Object.freeze({ + kind: "contract", + init, + name, + traits, + attributes, + declarations, + loc, + }); +export const isContract = ($value: Contract) => $value.kind === "contract"; +export type Trait = $.Trait; +export const Trait = ( + name: $c.TypeId, + traits: readonly $c.TypeId[], + attributes: readonly $.ContractAttribute[], + declarations: $.LocalItems, + loc: $c.Loc, +): $.Trait => + Object.freeze({ + kind: "trait", + name, + traits, + attributes, + declarations, + loc, + }); +export const isTrait = ($value: Trait) => $value.kind === "trait"; +export type TypeDecl = $.TypeDecl; +export type ModuleItems = $.ModuleItems; +export const ModuleItems = ( + functions: readonly $.Function[], + constants: readonly $.Constant[], + extensions: readonly $.Extension[], + types: readonly $.TypeDecl[], +): $.ModuleItems => + Object.freeze({ + functions, + constants, + extensions, + types, + }); +export type Module = $.Module; +export const Module = ( + imports: readonly $.Import[], + items: $.ModuleItems, +): $.Module => + Object.freeze({ + kind: "module", + imports, + items, + }); +export const isModule = ($value: Module) => $value.kind === "module"; +export type Source = $.Source; +export const Source = ( + file: string | undefined, + contents: string, + root: $.Module, +): $.Source => + Object.freeze({ + file, + contents, + root, + }); diff --git a/src/next/ast/generated/statement.ts b/src/next/ast/generated/statement.ts new file mode 100644 index 0000000000..aaf483d696 --- /dev/null +++ b/src/next/ast/generated/statement.ts @@ -0,0 +1,224 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $c from "@/next/ast/common"; +import type * as $e from "@/next/ast/expression"; +import type * as $t from "@/next/ast/type"; +import type * as $ from "@/next/ast/statement"; + +export type StatementLet = $.StatementLet; +export const StatementLet = ( + name: $c.OptionalId, + type_: $t.Type | undefined, + expression: $e.Expression, + loc: $c.Loc, +): $.StatementLet => + Object.freeze({ + kind: "statement_let", + name, + type: type_, + expression, + loc, + }); +export const isStatementLet = ($value: StatementLet) => + $value.kind === "statement_let"; +export type StatementReturn = $.StatementReturn; +export const StatementReturn = ( + expression: $e.Expression | undefined, + loc: $c.Loc, +): $.StatementReturn => + Object.freeze({ + kind: "statement_return", + expression, + loc, + }); +export const isStatementReturn = ($value: StatementReturn) => + $value.kind === "statement_return"; +export type StatementExpression = $.StatementExpression; +export const StatementExpression = ( + expression: $e.Expression, + loc: $c.Loc, +): $.StatementExpression => + Object.freeze({ + kind: "statement_expression", + expression, + loc, + }); +export const isStatementExpression = ($value: StatementExpression) => + $value.kind === "statement_expression"; +export type StatementAssign = $.StatementAssign; +export const StatementAssign = ( + path: $e.Expression, + expression: $e.Expression, + loc: $c.Loc, +): $.StatementAssign => + Object.freeze({ + kind: "statement_assign", + path, + expression, + loc, + }); +export const isStatementAssign = ($value: StatementAssign) => + $value.kind === "statement_assign"; +export type AugmentedAssignOperation = $.AugmentedAssignOperation; +export const allAugmentedAssignOperation: readonly $.AugmentedAssignOperation[] = + [ + "+=", + "-=", + "*=", + "/=", + "&&=", + "||=", + "%=", + "|=", + "<<=", + ">>=", + "&=", + "^=", + ]; +export type StatementAugmentedAssign = $.StatementAugmentedAssign; +export const StatementAugmentedAssign = ( + op: $.AugmentedAssignOperation, + path: $e.Expression, + expression: $e.Expression, + loc: $c.Loc, +): $.StatementAugmentedAssign => + Object.freeze({ + kind: "statement_augmentedassign", + op, + path, + expression, + loc, + }); +export const isStatementAugmentedAssign = ($value: StatementAugmentedAssign) => + $value.kind === "statement_augmentedassign"; +export type StatementDestruct = $.StatementDestruct; +export const StatementDestruct = ( + type_: $c.TypeId, + typeArgs: readonly $t.Type[], + identifiers: readonly (readonly [$c.Id, $c.OptionalId])[], + ignoreUnspecifiedFields: boolean, + expression: $e.Expression, + loc: $c.Loc, +): $.StatementDestruct => + Object.freeze({ + kind: "statement_destruct", + type: type_, + typeArgs, + identifiers, + ignoreUnspecifiedFields, + expression, + loc, + }); +export const isStatementDestruct = ($value: StatementDestruct) => + $value.kind === "statement_destruct"; +export type StatementBlock = $.StatementBlock; +export const StatementBlock = ( + statements: readonly $.Statement[], + loc: $c.Loc, +): $.StatementBlock => + Object.freeze({ + kind: "statement_block", + statements, + loc, + }); +export const isStatementBlock = ($value: StatementBlock) => + $value.kind === "statement_block"; +export type StatementForEach = $.StatementForEach; +export const StatementForEach = ( + keyName: $c.OptionalId, + valueName: $c.OptionalId, + map: $e.Expression, + statements: readonly $.Statement[], + loc: $c.Loc, +): $.StatementForEach => + Object.freeze({ + kind: "statement_foreach", + keyName, + valueName, + map, + statements, + loc, + }); +export const isStatementForEach = ($value: StatementForEach) => + $value.kind === "statement_foreach"; +export type CatchBlock = $.CatchBlock; +export const CatchBlock = ( + catchName: $c.OptionalId, + catchStatements: readonly $.Statement[], +): $.CatchBlock => + Object.freeze({ + name: catchName, + statements: catchStatements, + }); +export type StatementTry = $.StatementTry; +export const StatementTry = ( + statements: readonly $.Statement[], + catchBlock: $.CatchBlock | undefined, + loc: $c.Loc, +): $.StatementTry => + Object.freeze({ + kind: "statement_try", + statements, + catchBlock, + loc, + }); +export const isStatementTry = ($value: StatementTry) => + $value.kind === "statement_try"; +export type StatementRepeat = $.StatementRepeat; +export const StatementRepeat = ( + iterations: $e.Expression, + statements: readonly $.Statement[], + loc: $c.Loc, +): $.StatementRepeat => + Object.freeze({ + kind: "statement_repeat", + iterations, + statements, + loc, + }); +export const isStatementRepeat = ($value: StatementRepeat) => + $value.kind === "statement_repeat"; +export type StatementUntil = $.StatementUntil; +export const StatementUntil = ( + condition: $e.Expression, + statements: readonly $.Statement[], + loc: $c.Loc, +): $.StatementUntil => + Object.freeze({ + kind: "statement_until", + condition, + statements, + loc, + }); +export const isStatementUntil = ($value: StatementUntil) => + $value.kind === "statement_until"; +export type StatementWhile = $.StatementWhile; +export const StatementWhile = ( + condition: $e.Expression, + statements: readonly $.Statement[], + loc: $c.Loc, +): $.StatementWhile => + Object.freeze({ + kind: "statement_while", + condition, + statements, + loc, + }); +export const isStatementWhile = ($value: StatementWhile) => + $value.kind === "statement_while"; +export type StatementCondition = $.StatementCondition; +export const StatementCondition = ( + condition: $e.Expression, + trueStatements: readonly $.Statement[], + falseStatements: readonly $.Statement[] | undefined, + loc: $c.Loc, +): $.StatementCondition => + Object.freeze({ + kind: "statement_condition", + condition, + trueStatements, + falseStatements, + loc, + }); +export const isStatementCondition = ($value: StatementCondition) => + $value.kind === "statement_condition"; +export type Statement = $.Statement; diff --git a/src/next/ast/generated/type-basic.ts b/src/next/ast/generated/type-basic.ts new file mode 100644 index 0000000000..ecffa4b0d9 --- /dev/null +++ b/src/next/ast/generated/type-basic.ts @@ -0,0 +1,131 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $c from "@/next/ast/common"; +import type * as $ from "@/next/ast/type-basic"; + +export type BasicType = $.BasicType +export type Signedness = $.Signedness; +export const allSignedness: readonly $.Signedness[] = ["signed", "unsigned"]; +export type IFInt = $.IFInt; +export const IFInt = ( + sign: $.Signedness, + width: number, + loc: $c.Loc, +): $.IFInt => + Object.freeze({ + kind: "FInt", + sign, + width, + loc, + }); +export type VarIntWidth = $.VarIntWidth; +export const allVarIntWidth: readonly $.VarIntWidth[] = ["16", "32"]; +export type IFVarInt = $.IFVarInt; +export const IFVarInt = ( + sign: $.Signedness, + width: $.VarIntWidth, + loc: $c.Loc, +): $.IFVarInt => + Object.freeze({ + kind: "FVarInt", + sign, + width, + loc, + }); +export type IntFormat = $.IntFormat; +export type TInt = $.TInt; +export const TInt = (format: $.IntFormat, loc: $c.Loc): $.TInt => + Object.freeze({ + kind: "TyInt", + format, + loc, + }); +export type SFBits = $.SFBits; +export const SFBits = (bits: number, loc: $c.Loc): $.SFBits => + Object.freeze({ + kind: "SFBits", + bits, + loc, + }); +export type SFRemaining = $.SFRemaining; +export const SFRemaining = (loc: $c.Loc): $.SFRemaining => + Object.freeze({ + kind: "SFRemaining", + loc, + }); +export type SFDefault = $.SFDefault; +export const SFDefault = (loc: $c.Loc): $.SFDefault => + Object.freeze({ + kind: "SFDefault", + loc, + }); +export type SliceFormat = $.SliceFormat; +export type TSlice = $.TSlice; +export const TSlice = (format: $.SliceFormat, loc: $c.Loc): $.TSlice => + Object.freeze({ + kind: "TySlice", + format, + loc, + }); +export type RemFormat = $.RemFormat; +export type TCell = $.TCell; +export const TCell = (format: $.RemFormat, loc: $c.Loc): $.TCell => + Object.freeze({ + kind: "TyCell", + format, + loc, + }); +export type TBuilder = $.TBuilder; +export const TBuilder = (format: $.RemFormat, loc: $c.Loc): $.TBuilder => + Object.freeze({ + kind: "TyBuilder", + format, + loc, + }); +export type TUnit = $.TUnit; +export const TUnit = (loc: $c.Loc): $.TUnit => + Object.freeze({ + kind: "unit_type", + loc, + }); +export type TVoid = $.TVoid; +export const TVoid = (loc: $c.Loc): $.TVoid => + Object.freeze({ + kind: "TypeVoid", + loc, + }); +export type TNull = $.TNull; +export const TNull = (loc: $c.Loc): $.TNull => + Object.freeze({ + kind: "TypeNull", + loc, + }); +export type TBool = $.TBool; +export const TBool = (loc: $c.Loc): $.TBool => + Object.freeze({ + kind: "TypeBool", + loc, + }); +export type TAddress = $.TAddress; +export const TAddress = (loc: $c.Loc): $.TAddress => + Object.freeze({ + kind: "TypeAddress", + loc, + }); +export type TString = $.TString; +export const TString = (loc: $c.Loc): $.TString => + Object.freeze({ + kind: "TypeString", + loc, + }); +export type TStringBuilder = $.TStringBuilder; +export const TStringBuilder = (loc: $c.Loc): $.TStringBuilder => + Object.freeze({ + kind: "TypeStringBuilder", + loc, + }); +export type TStateInit = $.TStateInit; +export const TStateInit = (loc: $c.Loc): $.TStateInit => + Object.freeze({ + kind: "TypeStateInit", + loc, + }); diff --git a/src/next/ast/generated/type-self.ts b/src/next/ast/generated/type-self.ts new file mode 100644 index 0000000000..d7107fdabb --- /dev/null +++ b/src/next/ast/generated/type-self.ts @@ -0,0 +1,142 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $ from "@/next/ast/type-self"; +import type * as $c from "@/next/ast/common"; +import type * as $d from "@/next/ast/checked-type"; +import type { CTypeDeclRefable } from "@/next/ast/checked"; +import type { BasicType } from "@/next/ast/type-basic"; + +export type SGTBasic = $.SGTRef; +export const SGTBasic = ( + type: BasicType, + loc: $c.Loc, +): $.SGTBasic => + Object.freeze({ + ground: "yes", + kind: "basic", + type, + loc, + }); +export type SGTRef = $.SGTRef; +export const SGTRef = ( + name: $c.TypeId, + type: CTypeDeclRefable, + typeArgs: readonly $.SelfTypeGround[], + loc: $c.Loc, +): $.SGTRef => + Object.freeze({ + ground: "yes", + kind: "type_ref", + name, + type, + typeArgs, + loc, + }); +export type SGTMaybe = $.SGTMaybe; +export const SGTMaybe = ( + type_: $.SelfTypeGround, + loc: $c.Loc, +): $.SGTMaybe => + Object.freeze({ + ground: "yes", + kind: "TypeMaybe", + type: type_, + loc, + }); +export type SGTMap = $.SGTMap; +export const SGTMap = ( + key: $.SelfTypeGround, + value: $.SelfTypeGround, + loc: $c.Loc, +): $.SGTMap => + Object.freeze({ + ground: "yes", + kind: "map_type", + key, + value, + loc, + }); +export type SGTTuple = $.SGTTuple; +export const SGTTuple = ( + typeArgs: readonly $.SelfTypeGround[], + loc: $c.Loc, +): $.SGTTuple => + Object.freeze({ + ground: "yes", + kind: "tuple_type", + typeArgs, + loc, + }); +export type SGTTensor = $.SGTTensor; +export const SGTTensor = ( + typeArgs: readonly $.SelfTypeGround[], + loc: $c.Loc, +): $.SGTTensor => + Object.freeze({ + ground: "yes", + kind: "tensor_type", + typeArgs, + loc, + }); +export type SVTRef = $.SVTRef; +export const SVTRef = ( + name: $c.TypeId, + type: CTypeDeclRefable, + typeArgs: readonly $d.CTParamRef[], + loc: $c.Loc, +): $.SVTRef => + Object.freeze({ + ground: "no", + kind: "type_ref", + name, + type, + typeArgs, + loc, + }); +export type SVTMaybe = $.SVTMaybe; +export const SVTMaybe = ( + type_: $d.CTParamRef, + loc: $c.Loc, +): $.SVTMaybe => + Object.freeze({ + ground: "no", + kind: "TypeMaybe", + type: type_, + loc, + }); +export type SVTMap = $.SVTMap; +export const SVTMap = ( + key: $d.CTParamRef, + value: $d.CTParamRef, + loc: $c.Loc, +): $.SVTMap => + Object.freeze({ + ground: "no", + kind: "map_type", + key, + value, + loc, + }); +export type SVTTuple = $.SVTTuple; +export const SVTTuple = ( + typeArgs: readonly $d.CTParamRef[], + loc: $c.Loc, +): $.SVTTuple => + Object.freeze({ + ground: "no", + kind: "tuple_type", + typeArgs, + loc, + }); +export type SVTTensor = $.SVTTensor; +export const SVTTensor = ( + typeArgs: readonly $d.CTParamRef[], + loc: $c.Loc, +): $.SVTTensor => + Object.freeze({ + ground: "no", + kind: "tensor_type", + typeArgs, + loc, + }); +export type SelfType = $.SelfType; +export type SelfTypeGround = $.SelfTypeGround; diff --git a/src/next/ast/generated/type.ts b/src/next/ast/generated/type.ts new file mode 100644 index 0000000000..445d9e0836 --- /dev/null +++ b/src/next/ast/generated/type.ts @@ -0,0 +1,108 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type * as $c from "@/next/ast/common"; +import type * as $ from "@/next/ast/type"; +import type { BasicType } from "@/next/ast/type-basic"; + +export type TBasic = $.TTensor; +export const TBasic = ( + type: BasicType, + loc: $c.Loc, +): $.TBasic => + Object.freeze({ + kind: "basic", + type, + loc, + }); +export type TTensor = $.TTensor; +export const TTensor = ( + typeArgs: readonly $.Type[], + loc: $c.Loc, +): $.TTensor => + Object.freeze({ + kind: "tensor_type", + typeArgs, + loc, + }); +export type TTuple = $.TTuple; +export const TTuple = ( + typeArgs: readonly $.Type[], + loc: $c.Loc, +): $.TTuple => + Object.freeze({ + kind: "tuple_type", + typeArgs, + loc, + }); +export type TCons = $.TCons; +export const TCons = ( + name: $c.TypeId, + typeArgs: readonly $.Type[], + loc: $c.Loc, +): $.TCons => { + if (name.text === 'StateInit') debugger; + return Object.freeze({ + kind: "cons_type", + name, + typeArgs, + loc, + }); +}; +export type Type = $.Type; +export type TMap = $.TMap; +export const TMap = (key: $.Type, value: $.Type, loc: $c.Loc): $.TMap => + Object.freeze({ + kind: "map_type", + key, + value, + loc, + }); + +export type TBounced = $.TBounced; +export const TBounced = (type_: $.Type, loc: $c.Loc): $.TBounced => + Object.freeze({ + kind: "TypeBounced", + type: type_, + loc, + }); +export type TMaybe = $.TMaybe; +export const TMaybe = (type_: $.Type, loc: $c.Loc): $.TMaybe => + Object.freeze({ + kind: "TypeMaybe", + type: type_, + loc, + }); +export type TypedParameter = $.TypedParameter; +export const TypedParameter = ( + name: $c.OptionalId, + type_: $.Type, + loc: $c.Loc, +): $.TypedParameter => + Object.freeze({ + name, + type: type_, + loc, + }); +export type TFunction = $.TFunction; +export const TFunction = ( + typeParams: readonly $c.TypeId[], + params: readonly $.TypedParameter[], + returnType: $.Type, +): $.TFunction => + Object.freeze({ + typeParams, + params, + returnType, + }); +export type TMethod = $.TMethod; +export const TMethod = ( + typeParams: readonly $c.TypeId[], + self: $.Type, + args: readonly $.TypedParameter[], + returnType: $.Type, +): $.TMethod => + Object.freeze({ + typeParams, + self, + args, + returnType, + }); \ No newline at end of file diff --git a/src/next/ast/generated/value.ts b/src/next/ast/generated/value.ts new file mode 100644 index 0000000000..1f75cce599 --- /dev/null +++ b/src/next/ast/generated/value.ts @@ -0,0 +1,13 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import type { Loc } from "@/next/ast/common"; +import type * as $ from "@/next/ast/value"; + +export type VNumber = $.VNumber; +export const VNumber = (value: bigint, loc: Loc): $.VNumber => + Object.freeze({ + kind: "number", + value, + loc, + }); +export const isVNumber = ($value: VNumber) => $value.kind === "number"; +export type Value = $.Value; diff --git a/src/next/ast/generated/via.ts b/src/next/ast/generated/via.ts new file mode 100644 index 0000000000..6cd1e64a19 --- /dev/null +++ b/src/next/ast/generated/via.ts @@ -0,0 +1,53 @@ +import type * as $ from "@/next/ast/via"; +import type * as $c from "@/next/ast/common"; +import type { TactImport, TactSource } from "@/next/imports/source"; +import { hideProperty } from "@/utils/tricks"; + +export type Via = $.Via; +export type ViaBuiltin = $.ViaBuiltin; +export type ViaUser = $.ViaUser; +export type ViaMember = $.ViaMember; + +export const ViaBuiltin = (): $.ViaBuiltin => ({ kind: "builtin" }); + +// when something was just defined +export const ViaOrigin = (defLoc: $c.Loc, source: TactSource): $.ViaUser => { + const result: $.ViaUser = { + kind: "user", + imports: [], + defLoc, + source, + }; + hideProperty(result, "source"); + return result; +}; + +// when it came through an import +export const ViaImport = ( + throughImport: TactImport, + via: $.ViaUser, +): $.ViaUser => { + const result: $.ViaUser = { + kind: "user", + imports: [throughImport, ...via.imports], + defLoc: via.defLoc, + source: via.source, + }; + hideProperty(result, "source"); + return result; +}; + +export const ViaMemberOrigin = ( + parentName: string, + defLoc: $c.Loc, +): $.ViaMember => ({ defLoc, parentName, traits: [] }); + +export const ViaMemberTrait = ( + parentName: string, + defLoc: $c.Loc, + via: $.ViaMember, +): $.ViaMember => ({ + defLoc, + parentName, + traits: [[via.parentName, via.defLoc], ...via.traits], +}); diff --git a/src/next/ast/index.ts b/src/next/ast/index.ts new file mode 100644 index 0000000000..52b2b48610 --- /dev/null +++ b/src/next/ast/index.ts @@ -0,0 +1,24 @@ +export * from "@/next/ast/generated/common"; +export * from "@/next/ast/generated/type-basic"; + +export * from "@/next/ast/generated/root"; +export * from "@/next/ast/generated/expression"; +export * from "@/next/ast/generated/statement"; +export * from "@/next/ast/generated/type"; +export * from "@/next/ast/generated/type-self"; + +export * from "@/next/ast/generated/checked"; +export * from "@/next/ast/generated/checked-expr"; +export * from "@/next/ast/generated/checked-type"; +export * from "@/next/ast/generated/checked-stmt"; + +export * from "@/next/ast/generated/lowered"; +export * from "@/next/ast/generated/lowered-expr"; +export * from "@/next/ast/generated/lowered-type"; +export * from "@/next/ast/generated/lowered-stmt"; + +export * from "@/next/ast/generated/via"; +export * from "@/next/ast/generated/value"; +export * from "@/next/ast/generated/effects"; +export * from "@/next/ast/lazy"; +export * from "@/next/ast/errors"; diff --git a/src/next/ast/lazy.ts b/src/next/ast/lazy.ts new file mode 100644 index 0000000000..54334c82ba --- /dev/null +++ b/src/next/ast/lazy.ts @@ -0,0 +1,79 @@ +/* eslint-disable require-yield */ +import type { Loc } from "@/next/ast/common"; +import * as E from "@/next/ast/errors"; + +type Result = "waiting" | "running" | readonly [T]; + +export const printSym = Symbol("print"); + +export type Thunk = { + [printSym]: () => Result; +} & (() => E.Log); + +function Thunk( + force: () => E.Log, + onOccurs: () => E.Log, +): Thunk { + let result: Result = "waiting"; + function* delayed() { + if (typeof result !== "string") { + return result[0]; + } + if (result === "running") { + return yield* onOccurs(); + } + result = "running"; + const output = yield* force(); + result = [output]; + return output; + } + // @ts-expect-error TS bug. with text field name it works + delayed[printSym] = () => result; + return delayed; +} + +export const isThunk = (arg: object): arg is Thunk => printSym in arg; + +export const FakeThunk = (t: T): Thunk => { + function* thunk() { + return t; + } + // @ts-expect-error TS bug. with text field name it works + thunk[printSym] = () => [t] as const; + return thunk; +}; + +type Options = { + readonly loc: Loc; + readonly context: readonly E.TELine[]; + readonly recover: T; + readonly callback: (builder: ThunkBuilder) => E.Log; +}; + +export type ThunkBuilder = (options: Options) => Thunk; + +const makeBuilder = (allContext: readonly E.TELine[]): ThunkBuilder => { + return function addThunk(options: Options): Thunk { + return Thunk( + function force() { + const nextBuilder = makeBuilder([ + ...options.context, + ...allContext, + ]); + return options.callback(nextBuilder); + }, + function* onOccurs() { + yield EOccurs(options.loc, allContext); + return options.recover; + }, + ); + }; +}; + +const EOccurs = (loc: Loc, context: readonly E.TELine[]) => E.TcError( + loc, + E.TEText(`Recursive definition`), + ...context, +); + +export const thunkBuilder = makeBuilder([]); diff --git a/src/next/ast/lowered-expr.ts b/src/next/ast/lowered-expr.ts new file mode 100644 index 0000000000..b1401c986a --- /dev/null +++ b/src/next/ast/lowered-expr.ts @@ -0,0 +1,227 @@ +import type { Id, Loc, Ordered, TypeId } from "@/next/ast/common"; +import type { + BinaryOperation, + NumberBase, + UnaryOperation, +} from "@/next/ast/expression"; +// TODO: this seems incorrect +import type { SelfType } from "@/next/ast/type-self"; +import type { LTBasic, LType, LTMap, LTRef, LTTensor, LTTuple } from "@/next/ast/lowered-type"; + +export type LTypeArgs = ReadonlyMap; + +export type LExpr = + | LOpBinary + | LOpUnary + | LConditional + | LMethodCall + | LStaticCall + | LStaticMethodCall + | LFieldAccess + | LStructCons + | LInitOf + | LCodeOf + | LNumber + | LBoolean + | LNull + | LString + | LVar + | LSelf + | LUnit + | LTuple + | LTensor + | LMapLiteral + | LSetLiteral; + +export type LLValue = LLVar | LLSelf | LLFieldAccess; + +export type LLSelf = { + readonly kind: "self"; + readonly computedType: SelfType; + readonly loc: Loc; +}; + +export type LLVar = { + readonly kind: "var"; + readonly name: string; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LLFieldAccess = { + readonly kind: "field_access"; + readonly aggregate: LLValue; + readonly field: Id; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LSelf = { + readonly kind: "self"; + readonly computedType: SelfType; + readonly loc: Loc; +}; + +export type LVar = { + readonly kind: "var"; + readonly name: string; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LNumber = { + readonly kind: "number"; + readonly base: NumberBase; + readonly value: bigint; + readonly computedType: LTBasic; + readonly loc: Loc; +}; + +export type LBoolean = { + readonly kind: "boolean"; + readonly value: boolean; + readonly computedType: LTBasic; + readonly loc: Loc; +}; + +export type LString = { + readonly kind: "string"; + readonly value: string; + readonly computedType: LTBasic; + readonly loc: Loc; +}; + +export type LNull = { + readonly kind: "null"; + readonly computedType: LTBasic; + readonly loc: Loc; +}; + +export type LOpBinary = { + readonly kind: "op_binary"; + readonly op: BinaryOperation; + readonly left: LExpr; + readonly right: LExpr; + readonly typeArgs: LTypeArgs; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LOpUnary = { + readonly kind: "op_unary"; + readonly op: UnaryOperation; + readonly operand: LExpr; + readonly typeArgs: LTypeArgs; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LFieldAccess = { + readonly kind: "field_access"; + readonly aggregate: LExpr; + readonly field: Id; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LMethodCall = { + readonly kind: "method_call"; + readonly self: LExpr; + readonly method: Id; + // NB! these are substitutions to self type + readonly args: readonly LExpr[]; + readonly typeArgs: LTypeArgs; + readonly computedType: LType; + readonly loc: Loc; +}; + +// builtins or top-level (module) functions +export type LStaticCall = { + readonly kind: "static_call"; + readonly function: Id; + readonly typeArgs: LTypeArgs; + readonly args: readonly LExpr[]; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LStaticMethodCall = { + readonly kind: "static_method_call"; + readonly self: TypeId; + readonly typeArgs: LTypeArgs; + readonly function: Id; + readonly args: readonly LExpr[]; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LStructCons = { + readonly kind: "struct_instance"; + readonly fields: Ordered; + readonly computedType: LTRef; + readonly loc: Loc; +}; + +export type LMapLiteral = { + readonly kind: "map_literal"; + readonly fields: readonly LMapField[]; + readonly computedType: LTMap; + readonly loc: Loc; +}; + +export type LMapField = { + readonly key: LExpr; + readonly value: LExpr; +}; + +export type LSetLiteral = { + readonly kind: "set_literal"; + readonly valueType: LType; + readonly fields: readonly LExpr[]; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LInitOf = { + readonly kind: "init_of"; + readonly contract: TypeId; + readonly args: readonly LExpr[]; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LCodeOf = { + readonly kind: "code_of"; + readonly contract: TypeId; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LConditional = { + readonly kind: "conditional"; + readonly condition: LExpr; + readonly thenBranch: LExpr; + readonly elseBranch: LExpr; + readonly computedType: LType; + readonly loc: Loc; +}; + +export type LUnit = { + readonly kind: "unit"; + readonly computedType: LTBasic; + readonly loc: Loc; +}; + +export type LTuple = { + readonly kind: "tuple"; + readonly children: readonly LExpr[]; + readonly computedType: LTTuple; + readonly loc: Loc; +}; + +export type LTensor = { + readonly kind: "tensor"; + readonly children: readonly LExpr[]; + readonly computedType: LTTensor; + readonly loc: Loc; +}; diff --git a/src/next/ast/lowered-stmt.ts b/src/next/ast/lowered-stmt.ts new file mode 100644 index 0000000000..15c3ea7e0c --- /dev/null +++ b/src/next/ast/lowered-stmt.ts @@ -0,0 +1,124 @@ +import type { LExpr, LLValue } from "@/next/ast/lowered-expr"; +import type { Id, Loc, OptionalId, Ordered, TypeId } from "@/next/ast/common"; +import type { AugmentedAssignOperation } from "@/next/ast/statement"; + +export type LStmt = + | LStmtLet + | LStmtReturn + | LStmtExpression + | LStmtAssign + | LStmtAugmentedAssign + | LStmtCondition + | LStmtWhile + | LStmtUntil + | LStmtRepeat + | LStmtTry + | LStmtForEach + | LStmtDestruct + | LStmtBlock; + +export type LStmtList = readonly LStmt[]; + +export type LStmtLet = { + readonly kind: "let"; + readonly name: OptionalId; + readonly expression: LExpr; + readonly loc: Loc; +}; + +export type LStmtReturn = { + readonly kind: "return"; + readonly expression: LExpr | undefined; + readonly loc: Loc; +}; + +export type LStmtExpression = { + readonly kind: "expression"; + readonly expression: LExpr; + readonly loc: Loc; +}; + +export type LStmtAssign = { + readonly kind: "assign"; + readonly path: LLValue; + readonly expression: LExpr; + readonly loc: Loc; +}; + +export type LStmtAugmentedAssign = { + readonly kind: "augmentedassign"; + readonly op: AugmentedAssignOperation; + readonly path: LLValue; + readonly expression: LExpr; + readonly loc: Loc; +}; + +export type LStmtCondition = { + readonly kind: "condition"; + readonly condition: LExpr; + readonly trueStatements: LStmtList; + readonly falseStatements: LStmtList | undefined; + readonly loc: Loc; +}; + +export type LStmtWhile = { + readonly kind: "while"; + readonly condition: LExpr; + readonly statements: LStmtList; + readonly loc: Loc; +}; + +export type LStmtUntil = { + readonly kind: "until"; + readonly condition: LExpr; + readonly statements: LStmtList; + readonly loc: Loc; +}; + +export type LStmtRepeat = { + readonly kind: "repeat"; + readonly iterations: LExpr; + readonly statements: LStmtList; + readonly loc: Loc; +}; + +export type LStmtTry = { + readonly kind: "try"; + readonly statements: LStmtList; + readonly catchBlock: LCatchBlock | undefined; + readonly loc: Loc; +}; + +export type LCatchBlock = { + readonly name: OptionalId; + readonly statements: LStmtList; +}; + +export type LStmtForEach = { + readonly kind: "foreach"; + readonly keyName: OptionalId; + readonly valueName: OptionalId; + readonly map: LExpr; + readonly statements: LStmtList; + readonly loc: Loc; +}; + +export type LStmtDestruct = { + readonly kind: "destruct"; + readonly type: TypeId; + readonly identifiers: Ordered; + readonly ignoreUnspecifiedFields: boolean; + readonly expression: LExpr; + readonly loc: Loc; +}; + +export type LDestructPattern = { + readonly field: Id; + readonly variable: OptionalId; +}; + +export type LStmtBlock = { + readonly kind: "block"; + readonly statements: LStmtList; + readonly loc: Loc; +}; diff --git a/src/next/ast/lowered-type.ts b/src/next/ast/lowered-type.ts new file mode 100644 index 0000000000..0c62047d89 --- /dev/null +++ b/src/next/ast/lowered-type.ts @@ -0,0 +1,76 @@ +import type { CTypeDeclRefable } from "@/next/ast/checked"; +import type { Loc, TypeId } from "@/next/ast/common"; +import type { BasicType } from "@/next/ast/type-basic"; + +export type LType = + | LTRef + | LTAliasRef + | LTParamRef + | LTMap + | LTBounced + | LTMaybe + | LTTuple + | LTTensor + | LTBasic; + +export type LTBasic = { + readonly kind: "basic"; + readonly type: BasicType; + readonly loc: Loc; +}; + +export type LTRef = { + readonly kind: "type_ref"; + readonly name: TypeId; + readonly type: CTypeDeclRefable; + readonly typeArgs: readonly LType[]; + // readonly funcType: Lazy; + // readonly alloc: Lazy + readonly loc: Loc; +}; + +export type LTAliasRef = { + readonly kind: "TypeAlias"; + readonly name: TypeId; + readonly type: LType; + readonly typeArgs: readonly LType[]; + readonly loc: Loc; +}; + +export type LTParamRef = { + readonly kind: "TypeParam"; + readonly name: TypeId; + readonly loc: Loc; +}; + +export type LTBounced = { + readonly kind: "TypeBounced"; + // name of the message type + readonly name: TypeId; + readonly loc: Loc; +}; + +export type LTMaybe = { + readonly kind: "TypeMaybe"; + readonly type: LType; + readonly loc: Loc; +}; + +export type LTMap = { + readonly kind: "map_type"; + readonly key: LType; + readonly value: LType; + readonly loc: Loc; +}; + +export type LTTuple = { + readonly kind: "tuple_type"; + readonly typeArgs: readonly LType[]; + readonly loc: Loc; +}; + +export type LTTensor = { + readonly kind: "tensor_type"; + readonly typeArgs: readonly LType[]; + readonly loc: Loc; +}; diff --git a/src/next/ast/lowered.ts b/src/next/ast/lowered.ts new file mode 100644 index 0000000000..67e390f7eb --- /dev/null +++ b/src/next/ast/lowered.ts @@ -0,0 +1,228 @@ +import type { Effects } from "@/next/ast/effects"; +import type { LStmt } from "@/next/ast/lowered-stmt"; +import type { FuncId, Loc, OptionalId, Ordered, TypeId } from "@/next/ast/common"; +import type { LType, LTRef, LTBounced } from "@/next/ast/lowered-type"; +import type { SelfType } from "@/next/ast/type-self"; +import type { + AsmInstruction, + AsmShuffle, + ContractAttribute, +} from "@/next/ast/root"; +import type { Value } from "@/next/ast/value"; + +export type LSource = { + readonly typeDecls: ReadonlyMap; + readonly functions: ReadonlyMap; + readonly constants: ReadonlyMap; + readonly extensions: ReadonlyMap; +}; + +export type LTypeDecl = + | LAlias + | LContract + | LTrait + | LStruct + | LMessage + | LUnion; + +export type LTypeDeclRefable = + | LContract + | LStruct + | LMessage + | LUnion; + +export type LConstant = { + readonly initializer: Value; + readonly type: LType; +}; + +export type LFunction = { + readonly type: LTFunction; + readonly inline: boolean; + readonly body: LBody; +}; + +export type LStatements = { + readonly body: readonly LStmt[]; + readonly effects: Effects; +}; + +export type LBody = LTactBody | LFuncBody | LFiftBody; + +export type LTactBody = { + readonly kind: "tact"; + readonly statements: LStatements; +}; +export type LFuncBody = { + readonly kind: "func"; + readonly nativeName: FuncId; +}; +export type LFiftBody = { + readonly kind: "fift"; + readonly shuffle: AsmShuffle; + readonly instructions: readonly AsmInstruction[]; +}; + +export type LExtension = { + readonly type: LTMethod; + readonly inline: boolean; + readonly body: LBody; +}; + +export type LAlias = { + readonly kind: "alias"; + readonly typeParams: LTypeParams; + readonly type: LType; +}; + +export type LInit = LInitEmpty | LInitSimple | LInitFn; +export type LInitEmpty = { + readonly kind: "empty"; + // initOf() would take 0 parameters + // values to fill all the fields + readonly fill: Ordered; +}; +export type LInitSimple = { + readonly kind: "simple"; + // initOf() takes these parameters and + // sets them into correspondingly named fields + readonly fill: Ordered; + readonly loc: Loc; +}; +export type LInitFn = { + readonly kind: "function"; + // here we just specify the function + readonly params: LParameters; + readonly statements: LStatements; +}; +export type LInitParam = { + readonly type: LType; + readonly init: undefined | Value; + readonly loc: Loc; +}; + +export type LContract = { + readonly kind: "contract"; + readonly attributes: readonly ContractAttribute[]; + readonly init: LInit; + readonly content: LContractMembers; +}; +export type LContractMembers = LMembers; +export type LTrait = { + readonly kind: "trait"; + readonly content: LTraitMembers; +}; +export type LTraitMembers = LMembers; +export type LMembers = { + readonly fieldish: Ordered>; + readonly methods: ReadonlyMap>; + readonly receivers: LReceivers; +}; +export type LReceivers = { + readonly bounce: LBounce; + readonly internal: LReceiver; + readonly external: LReceiver; +}; + +export type LFieldish = LField | LFieldConstant; +export type LField = { + readonly kind: "field"; + readonly type: LType; + readonly init: Value | undefined; +}; +export type LFieldConstant = { + readonly kind: "constant"; + readonly type: LType; + readonly init: Expr; +}; + +export type LMethod = { + readonly type: LTMethod; + readonly inline: boolean; + readonly body: Body; + readonly getMethodId: bigint | undefined; +}; + +export type LBounce = { + // NB! can't compute opcodes until all receivers are present + readonly message: readonly LReceiverMessage[]; + readonly messageAny: undefined | LReceiverAny; +}; + +export type LReceiver = { + // NB! can't compute opcodes until all receivers are present + readonly message: readonly LReceiverOpcode[]; + readonly messageAny: undefined | LReceiverAny; + readonly stringAny: undefined | LReceiverAny; + readonly empty: undefined | LReceiverEmpty; +}; + +export type LReceiverOpcode = LReceiverMessage | LReceiverString; +export type LReceiverMessage = { + readonly kind: "binary"; + readonly name: OptionalId; + readonly type: LTRef | LTBounced; + readonly statements: LStatements; +}; +export type LReceiverAny = { + readonly name: OptionalId; + readonly statements: LStatements; +}; +export type LReceiverString = { + readonly kind: "string"; + readonly comment: string; + readonly statements: LStatements; +}; +export type LReceiverEmpty = { + readonly statements: LStatements; +}; + +export type LStruct = { + readonly kind: "struct"; + readonly typeParams: LTypeParams; + readonly fields: Ordered; +}; + +export type LMessage = { + readonly kind: "message"; + readonly opcode: bigint; + readonly fields: Ordered; +}; + +export type LUnion = { + readonly kind: "union"; + readonly typeParams: LTypeParams; + readonly cases: ReadonlyMap>; +}; + +export type LTFunction = { + readonly kind: "DecodedFnType"; + readonly typeParams: LTypeParams; + readonly params: LParameters; + readonly returnType: LType; +}; + +export type LTMethod = { + readonly kind: "DecodedMethodType"; + readonly mutates: boolean; + readonly typeParams: LTypeParams; + readonly self: SelfType; + readonly params: LParameters; + readonly returnType: LType; +}; + +export type LParameter = { + readonly name: OptionalId; + readonly type: LType; + readonly loc: Loc; +}; + +export type LParameters = { + readonly order: readonly LParameter[]; + readonly set: ReadonlySet; +}; + +export type LTypeParams = { + readonly order: readonly TypeId[]; + readonly set: ReadonlySet; +}; diff --git a/src/next/ast/root.ts b/src/next/ast/root.ts new file mode 100644 index 0000000000..648c406d1c --- /dev/null +++ b/src/next/ast/root.ts @@ -0,0 +1,249 @@ +import type { FuncId, Id, Loc, TypeId, Language } from "@/next/ast/common"; +import type { Expression, Number, String } from "@/next/ast/expression"; +import type { Statement } from "@/next/ast/statement"; +import type { TFunction, Type, TypedParameter } from "@/next/ast/type"; +import type { RelativePath } from "@/next/fs"; + +export type Source = { + readonly file: string | undefined; + readonly contents: string; + readonly root: Module; +}; + +export type Module = { + readonly kind: "module"; + readonly imports: readonly Import[]; + readonly items: ModuleItems; +}; +export type ModuleItems = { + readonly functions: readonly Function[]; + readonly constants: readonly Constant[]; + readonly extensions: readonly Extension[]; + readonly types: readonly TypeDecl[]; +}; +export type TypeDecl = + | StructDecl + | MessageDecl + | UnionDecl + | AliasDecl + | Contract + | Trait; +export type Import = { + readonly kind: "import"; + readonly importPath: ImportPath; + readonly loc: Loc; +}; +// Reference to source file +export type ImportPath = { + readonly path: RelativePath; + readonly type: ImportType; + readonly language: Language; +}; +// This is different from ItemOrigin, because relative import +// from standard library is still import with origin: "stdlib" +export type ImportType = "stdlib" | "relative"; + +export type Contract = { + readonly kind: "contract"; + readonly init: undefined | Init; + + readonly name: TypeId; + readonly traits: readonly TypeId[]; + readonly attributes: readonly ContractAttribute[]; + readonly declarations: LocalItems; + readonly loc: Loc; +}; + +export type Init = InitFunction | InitParams; +export type InitFunction = { + readonly kind: "init_function"; + readonly params: readonly TypedParameter[]; + readonly statements: readonly Statement[]; + readonly loc: Loc; +}; +export type InitParams = { + readonly kind: "init_params"; + readonly params: readonly FieldDecl[]; + readonly loc: Loc; +}; + +export type Trait = { + readonly kind: "trait"; + + readonly name: TypeId; + readonly traits: readonly TypeId[]; + readonly attributes: readonly ContractAttribute[]; + readonly declarations: LocalItems; + readonly loc: Loc; +}; + +export type LocalItems = { + readonly fields: readonly FieldDecl[]; + readonly methods: readonly Method[]; + readonly receivers: readonly Receiver[]; + readonly constants: readonly FieldConstant[]; +}; + +export type ContractAttribute = { + readonly type: "interface"; + readonly name: string; + readonly loc: Loc; +}; + +export type Extension = { + readonly kind: "extension"; + readonly mutates: boolean; + readonly fun: Function; + readonly selfType: Type; +}; + +export type Method = { + readonly kind: "method"; + readonly mutates: boolean; + readonly overridable: boolean; + readonly override: boolean; + readonly get: undefined | GetAttribute; + readonly fun: Function; +}; + +export type GetAttribute = { + readonly methodId: Expression | undefined; + readonly loc: Loc; +}; + +export type Function = { + readonly kind: "function"; + readonly inline: boolean; + readonly name: Id; + readonly type: TFunction; + readonly body: FunctionalBody; + readonly loc: Loc; +}; + +export type FunctionalBody = RegularBody | AsmBody | NativeBody | AbstractBody; +export type AbstractBody = { + readonly kind: "abstract_body"; +}; +export type RegularBody = { + readonly kind: "regular_body"; + readonly statements: readonly Statement[]; +}; +export type NativeBody = { + readonly kind: "native_body"; + readonly nativeName: FuncId; +}; +export type AsmBody = { + readonly kind: "asm_body"; + readonly shuffle: AsmShuffle; + readonly instructions: readonly AsmInstruction[]; +}; +export type AsmInstruction = string; +export type AsmShuffle = { + readonly args: readonly Id[]; + readonly ret: readonly Number[]; +}; + +export type FieldConstant = { + readonly kind: "field_const"; + readonly overridable: boolean; + readonly override: boolean; + readonly body: Constant; +}; +export type Constant = { + readonly kind: "constant"; + readonly name: Id; + readonly init: ConstantInit; + readonly loc: Loc; +}; +export type ConstantInit = ConstantDef | ConstantDecl; +export type ConstantDef = { + readonly kind: "constant_def"; + readonly type: Type | undefined; + readonly initializer: Expression; +}; +export type ConstantDecl = { + readonly kind: "constant_decl"; + readonly type: Type; +}; + +export type StructDecl = { + readonly kind: "struct_decl"; + readonly name: TypeId; + readonly typeParams: readonly TypeId[]; + readonly fields: readonly FieldDecl[]; + readonly loc: Loc; +}; + +export type MessageDecl = { + readonly kind: "message_decl"; + readonly name: TypeId; + readonly opcode: Expression | undefined; + readonly fields: readonly FieldDecl[]; + readonly loc: Loc; +}; + +export type UnionDecl = { + readonly kind: "union_decl"; + readonly name: TypeId; + readonly typeParams: readonly TypeId[]; + readonly cases: readonly UnionCase[]; + readonly loc: Loc; +}; +export type UnionCase = { + readonly name: TypeId; + readonly fields: readonly FieldDecl[]; +}; + +export type AliasDecl = { + readonly kind: "alias_decl"; + readonly name: TypeId; + readonly typeParams: readonly TypeId[]; + readonly type: Type; + readonly loc: Loc; +}; + +export type FieldDecl = { + readonly kind: "field_decl"; + readonly name: Id; + readonly type: Type; + readonly initializer: Expression | undefined; + readonly loc: Loc; +}; + +export type Receiver = { + readonly kind: "receiver"; + readonly selector: ReceiverKind; + readonly statements: readonly Statement[]; + readonly loc: Loc; +}; +export type ReceiverSimple = { + readonly kind: "simple"; + readonly param: TypedParameter; +}; +export type ReceiverFallback = { + readonly kind: "fallback"; +}; +export type ReceiverComment = { + readonly kind: "comment"; + readonly comment: String; +}; +export type ReceiverSubKind = + | ReceiverSimple + | ReceiverFallback + | ReceiverComment; +export type ReceiverInternal = { + readonly kind: "internal"; + readonly subKind: ReceiverSubKind; + readonly loc: Loc; +}; +export type ReceiverExternal = { + readonly kind: "external"; + readonly subKind: ReceiverSubKind; + readonly loc: Loc; +}; +export type ReceiverBounce = { + readonly kind: "bounce"; + readonly param: TypedParameter; + readonly loc: Loc; +}; +export type ReceiverKind = ReceiverInternal | ReceiverExternal | ReceiverBounce; diff --git a/src/next/ast/statement.ts b/src/next/ast/statement.ts new file mode 100644 index 0000000000..b88c118136 --- /dev/null +++ b/src/next/ast/statement.ts @@ -0,0 +1,133 @@ +import type { Id, Loc, OptionalId, TypeId } from "@/next/ast/common"; +import type { Expression } from "@/next/ast/expression"; +import type { Type } from "@/next/ast/type"; + +export type Statement = + | StatementLet + | StatementReturn + | StatementExpression + | StatementAssign + | StatementAugmentedAssign + | StatementCondition + | StatementWhile + | StatementUntil + | StatementRepeat + | StatementTry + | StatementForEach + | StatementDestruct + | StatementBlock; + +export type StatementLet = { + readonly kind: "statement_let"; + readonly name: OptionalId; + readonly type: Type | undefined; + readonly expression: Expression; + readonly loc: Loc; +}; + +export type StatementReturn = { + readonly kind: "statement_return"; + readonly expression: Expression | undefined; + readonly loc: Loc; +}; + +export type StatementExpression = { + readonly kind: "statement_expression"; + readonly expression: Expression; + readonly loc: Loc; +}; + +export type StatementAssign = { + readonly kind: "statement_assign"; + readonly path: Expression; // left-hand side of `=` + readonly expression: Expression; + readonly loc: Loc; +}; + +export type AugmentedAssignOperation = + | "+=" + | "-=" + | "*=" + | "/=" + | "&&=" + | "||=" + | "%=" + | "|=" + | "<<=" + | ">>=" + | "&=" + | "^="; + +export type StatementAugmentedAssign = { + readonly kind: "statement_augmentedassign"; + readonly op: AugmentedAssignOperation; + readonly path: Expression; + readonly expression: Expression; + readonly loc: Loc; +}; + +export type StatementCondition = { + readonly kind: "statement_condition"; + readonly condition: Expression; + readonly trueStatements: readonly Statement[]; + readonly falseStatements: readonly Statement[] | undefined; + readonly loc: Loc; +}; + +export type StatementWhile = { + readonly kind: "statement_while"; + readonly condition: Expression; + readonly statements: readonly Statement[]; + readonly loc: Loc; +}; + +export type StatementUntil = { + readonly kind: "statement_until"; + readonly condition: Expression; + readonly statements: readonly Statement[]; + readonly loc: Loc; +}; + +export type StatementRepeat = { + readonly kind: "statement_repeat"; + readonly iterations: Expression; + readonly statements: readonly Statement[]; + readonly loc: Loc; +}; + +export type StatementTry = { + readonly kind: "statement_try"; + readonly statements: readonly Statement[]; + readonly catchBlock: CatchBlock | undefined; + readonly loc: Loc; +}; + +export type CatchBlock = { + readonly name: OptionalId; + readonly statements: readonly Statement[]; +}; + +export type StatementForEach = { + readonly kind: "statement_foreach"; + readonly keyName: OptionalId; + readonly valueName: OptionalId; + readonly map: Expression; + readonly statements: readonly Statement[]; + readonly loc: Loc; +}; + +export type StatementDestruct = { + readonly kind: "statement_destruct"; + readonly type: TypeId; + readonly typeArgs: readonly Type[]; + readonly identifiers: readonly (readonly [Id, OptionalId])[]; + readonly ignoreUnspecifiedFields: boolean; + readonly expression: Expression; + readonly loc: Loc; +}; + +export type StatementBlock = { + readonly kind: "statement_block"; + readonly statements: readonly Statement[]; + readonly loc: Loc; +}; diff --git a/src/next/ast/type-basic.ts b/src/next/ast/type-basic.ts new file mode 100644 index 0000000000..f9c060b5b8 --- /dev/null +++ b/src/next/ast/type-basic.ts @@ -0,0 +1,107 @@ +import type { Loc } from "@/next/ast/common"; + +export type BasicType = TInt + | TSlice + | TCell + | TBuilder + | TUnit + | TVoid + | TNull + | TBool + | TAddress + | TStateInit + | TString + | TStringBuilder + +export type TUnit = { + readonly kind: "unit_type"; + readonly loc: Loc; +}; + +export type TInt = { + readonly kind: "TyInt"; + readonly format: IntFormat; + readonly loc: Loc; +}; +export type IntFormat = IFInt | IFVarInt; +export type IFInt = { + readonly kind: "FInt"; + readonly sign: Signedness; + readonly width: number; + readonly loc: Loc; +}; +export type IFVarInt = { + readonly kind: "FVarInt"; + readonly sign: Signedness; + readonly width: VarIntWidth; + readonly loc: Loc; +}; +export type VarIntWidth = "16" | "32"; +export type Signedness = "signed" | "unsigned"; + +export type TSlice = { + readonly kind: "TySlice"; + readonly format: SliceFormat; + readonly loc: Loc; +}; +export type SliceFormat = SFBits | SFRemaining | SFDefault; +export type SFBits = { + readonly kind: "SFBits"; + readonly bits: number; + readonly loc: Loc; +}; +export type SFRemaining = { + readonly kind: "SFRemaining"; + readonly loc: Loc; +}; +export type SFDefault = { + readonly kind: "SFDefault"; + readonly loc: Loc; +}; + +export type TCell = { + readonly kind: "TyCell"; + readonly format: RemFormat; + readonly loc: Loc; +}; +export type TBuilder = { + readonly kind: "TyBuilder"; + readonly format: RemFormat; + readonly loc: Loc; +}; +export type RemFormat = SFRemaining | SFDefault; + +export type TVoid = { + readonly kind: "TypeVoid"; + readonly loc: Loc; +}; + +export type TNull = { + readonly kind: "TypeNull"; + readonly loc: Loc; +}; + +export type TBool = { + readonly kind: "TypeBool"; + readonly loc: Loc; +}; + +export type TAddress = { + readonly kind: "TypeAddress"; + readonly loc: Loc; +}; + +export type TStateInit = { + readonly kind: "TypeStateInit"; + readonly loc: Loc; +}; + +export type TString = { + readonly kind: "TypeString"; + readonly loc: Loc; +}; + +export type TStringBuilder = { + readonly kind: "TypeStringBuilder"; + readonly loc: Loc; +}; \ No newline at end of file diff --git a/src/next/ast/type-self.ts b/src/next/ast/type-self.ts new file mode 100644 index 0000000000..2fbdabe0f0 --- /dev/null +++ b/src/next/ast/type-self.ts @@ -0,0 +1,103 @@ +import type { CTypeDeclRefable } from "@/next/ast/checked"; +import type { Loc, TypeId } from "@/next/ast/common"; +import type { CTParamRef } from "@/next/ast/checked-type"; +import type { BasicType } from "@/next/ast/type-basic"; + +export type SelfType = + | SelfTypeGround + | SVTRef + | SVTMap + | SVTMaybe + | SVTTuple + | SVTTensor; + +export type SelfTypeGround = + | SGTRef + | SGTMap + | SGTMaybe + | SGTTuple + | SGTTensor + | SGTBasic; + +export type SGTBasic = { + readonly ground: "yes"; + readonly kind: "basic"; + readonly type: BasicType; + readonly loc: Loc; +}; + +export type SGTRef = { + readonly ground: "yes"; + readonly kind: "type_ref"; + readonly name: TypeId; + readonly type: CTypeDeclRefable; + readonly typeArgs: readonly SelfTypeGround[]; + readonly loc: Loc; +}; + +export type SGTMaybe = { + readonly ground: "yes"; + readonly kind: "TypeMaybe"; + readonly type: SelfTypeGround; + readonly loc: Loc; +}; + +export type SGTMap = { + readonly ground: "yes"; + readonly kind: "map_type"; + readonly key: SelfTypeGround; + readonly value: SelfTypeGround; + readonly loc: Loc; +}; + +export type SGTTuple = { + readonly ground: "yes"; + readonly kind: "tuple_type"; + readonly typeArgs: readonly SelfTypeGround[]; + readonly loc: Loc; +}; + +export type SGTTensor = { + readonly ground: "yes"; + readonly kind: "tensor_type"; + readonly typeArgs: readonly SelfTypeGround[]; + readonly loc: Loc; +}; + +export type SVTRef = { + readonly ground: "no"; + readonly kind: "type_ref"; + readonly name: TypeId; + readonly type: CTypeDeclRefable; + readonly typeArgs: readonly CTParamRef[]; + readonly loc: Loc; +}; + +export type SVTMaybe = { + readonly ground: "no"; + readonly kind: "TypeMaybe"; + readonly type: CTParamRef; + readonly loc: Loc; +}; + +export type SVTMap = { + readonly ground: "no"; + readonly kind: "map_type"; + readonly key: CTParamRef; + readonly value: CTParamRef; + readonly loc: Loc; +}; + +export type SVTTuple = { + readonly ground: "no"; + readonly kind: "tuple_type"; + readonly typeArgs: readonly CTParamRef[]; + readonly loc: Loc; +}; + +export type SVTTensor = { + readonly ground: "no"; + readonly kind: "tensor_type"; + readonly typeArgs: readonly CTParamRef[]; + readonly loc: Loc; +}; diff --git a/src/next/ast/type.ts b/src/next/ast/type.ts new file mode 100644 index 0000000000..d59d2ab63e --- /dev/null +++ b/src/next/ast/type.ts @@ -0,0 +1,74 @@ +import type { Loc, OptionalId, TypeId } from "@/next/ast/common"; +import type { BasicType } from "@/next/ast/type-basic"; + +export type TFunction = { + readonly typeParams: readonly TypeId[]; + readonly params: readonly TypedParameter[]; + readonly returnType: Type; +}; + +export type TMethod = { + readonly typeParams: readonly TypeId[]; + readonly self: Type; + readonly args: readonly TypedParameter[]; + readonly returnType: Type; +}; + +export type TypedParameter = { + readonly name: OptionalId; + readonly type: Type; + readonly loc: Loc; +}; + +export type Type = + | TMap + | TCons + | TTuple + | TTensor + | TBounced + | TMaybe + | TBasic; + +export type TBasic = { + readonly kind: "basic"; + readonly type: BasicType; + readonly loc: Loc; +}; + +export type TCons = { + readonly kind: "cons_type"; + readonly name: TypeId; + readonly typeArgs: readonly Type[]; + readonly loc: Loc; +}; + +export type TBounced = { + readonly kind: "TypeBounced"; + readonly type: Type; + readonly loc: Loc; +}; + +export type TMaybe = { + readonly kind: "TypeMaybe"; + readonly type: Type; + readonly loc: Loc; +}; + +export type TTuple = { + readonly kind: "tuple_type"; + readonly typeArgs: readonly Type[]; + readonly loc: Loc; +}; + +export type TTensor = { + readonly kind: "tensor_type"; + readonly typeArgs: readonly Type[]; + readonly loc: Loc; +}; + +export type TMap = { + readonly kind: "map_type"; + readonly key: Type; // any type except tensor + readonly value: Type; // any type except tensor + readonly loc: Loc; +}; diff --git a/src/next/ast/value.ts b/src/next/ast/value.ts new file mode 100644 index 0000000000..9ba2f39770 --- /dev/null +++ b/src/next/ast/value.ts @@ -0,0 +1,10 @@ +import type { Loc } from "@/next/ast/common"; + +export type Value = VNumber; + +export type VNumber = { + readonly kind: "number"; + readonly value: bigint; + // loc of expression that resulted in this value + readonly loc: Loc; +}; diff --git a/src/next/ast/via.ts b/src/next/ast/via.ts new file mode 100644 index 0000000000..a7bf9e0876 --- /dev/null +++ b/src/next/ast/via.ts @@ -0,0 +1,27 @@ +import type { TactImport, TactSource } from "@/next/imports/source"; + +import type * as Ast from "@/next/ast"; + +// provenance for definition: where did it come from +export type Via = ViaUser | ViaBuiltin; + +// is defined in compiler, always was there +export type ViaBuiltin = { + readonly kind: "builtin"; +}; + +export type ViaUser = { + readonly kind: "user"; + // which imports it came through + readonly imports: readonly TactImport[]; + // where in the code it was defined + readonly defLoc: Ast.Loc; + // in which source + readonly source: TactSource; +}; + +export type ViaMember = { + readonly traits: readonly [string, Ast.Loc][]; + readonly defLoc: Ast.Loc; + readonly parentName: string; +}; diff --git a/src/next/example/alias.tact b/src/next/example/alias.tact new file mode 100644 index 0000000000..71ef243c76 --- /dev/null +++ b/src/next/example/alias.tact @@ -0,0 +1 @@ +type Foo = map; diff --git a/src/next/example/generic.tact b/src/next/example/generic.tact new file mode 100644 index 0000000000..7fa1ae69cf --- /dev/null +++ b/src/next/example/generic.tact @@ -0,0 +1,42 @@ +const m = emptyMap(); + +struct MapLen { + m: map; + l: Int as uint32; + // fun get(self: MapLen, key: K): V? { + // return self.m.get(key); + // } +} + +extends fun get(self: MapLen, key: K): V? { + return self.m.get(key); +} + +extends mutates fun set(self: MapLen, key: K, value: V) { + if (self.m.has(key)) { + self.m.set(key, value); + if (value == null) { + self.l -= 1; + } + } else { + self.m.set(key, value); + if (value != null) { + self.l += 1; + } + } +} + +// template +// std::optional MapLen::get(key: K) { +// } + +// const m = f < x > (1); +// const m =(f < x)> (1); + +// fun f() {} + +// fun f(a: A, b: B) {} +// fun g(x: X, y: Y) { +// f(x, y); +// f(y, x); +// } \ No newline at end of file diff --git a/src/next/example/import0.tact b/src/next/example/import0.tact new file mode 100644 index 0000000000..e83dc2ab33 --- /dev/null +++ b/src/next/example/import0.tact @@ -0,0 +1,13 @@ +import { h } from "./import1"; + +fun f(x: Int) { + return x + 1; +} + +contract G() { + receive() {} + + get fun g(): Int { + return f(41); + } +} \ No newline at end of file diff --git a/src/next/example/import1.tact b/src/next/example/import1.tact new file mode 100644 index 0000000000..1a3a6edb80 --- /dev/null +++ b/src/next/example/import1.tact @@ -0,0 +1,14 @@ +import { f } from "./import2"; +export { f } from "./import2"; + +export fun h(x: Int) { + return x - 1; +} + +contract F() { + receive() {} + + get fun g(): Int { + return f(41); + } +} diff --git a/src/next/example/import2.tact b/src/next/example/import2.tact new file mode 100644 index 0000000000..33d331d131 --- /dev/null +++ b/src/next/example/import2.tact @@ -0,0 +1,3 @@ +export fun f(x: Int) { + return x + 1; +} diff --git a/src/next/example/map-len.tact b/src/next/example/map-len.tact new file mode 100644 index 0000000000..feffc1ae08 --- /dev/null +++ b/src/next/example/map-len.tact @@ -0,0 +1,30 @@ +struct MapL { + m: map; + l: uint16; +} + +extends fun get(self: MapL, key: K): V? { + return self.m.get(key); +} + +extends mutates fun set(self: MapL, key: K, value: V) { + if (!self.m.exists(key)) { + self.l += 1; + } + self.m.set(key, value); +} + +message Set { + key: uint8; + value: uint8; +} + +contract Test { + state: MapL; + receive(msg: Set) { + self.state.set(msg.key, msg.value); + } + get fun state(): MapL { + return self.state; + } +} diff --git a/src/next/example/mutual1.tact b/src/next/example/mutual1.tact new file mode 100644 index 0000000000..55be01259a --- /dev/null +++ b/src/next/example/mutual1.tact @@ -0,0 +1 @@ +import "./mutual2"; diff --git a/src/next/example/mutual2.tact b/src/next/example/mutual2.tact new file mode 100644 index 0000000000..a2c0044033 --- /dev/null +++ b/src/next/example/mutual2.tact @@ -0,0 +1 @@ +import "./mutual1"; diff --git a/src/next/example/scope1-a.tact b/src/next/example/scope1-a.tact new file mode 100644 index 0000000000..558ffa99f4 --- /dev/null +++ b/src/next/example/scope1-a.tact @@ -0,0 +1,2 @@ +import "./scope1-b"; +import "./scope1-c"; diff --git a/src/next/example/scope1-b.tact b/src/next/example/scope1-b.tact new file mode 100644 index 0000000000..14f28127d3 --- /dev/null +++ b/src/next/example/scope1-b.tact @@ -0,0 +1 @@ +fun f(): Int { return 1; } \ No newline at end of file diff --git a/src/next/example/scope1-c.tact b/src/next/example/scope1-c.tact new file mode 100644 index 0000000000..14f28127d3 --- /dev/null +++ b/src/next/example/scope1-c.tact @@ -0,0 +1 @@ +fun f(): Int { return 1; } \ No newline at end of file diff --git a/src/next/example/scope2-a.tact b/src/next/example/scope2-a.tact new file mode 100644 index 0000000000..59e6cd9c25 --- /dev/null +++ b/src/next/example/scope2-a.tact @@ -0,0 +1,2 @@ +import "./scope2-b"; +import "./scope2-c"; diff --git a/src/next/example/scope2-b.tact b/src/next/example/scope2-b.tact new file mode 100644 index 0000000000..0024bfb41a --- /dev/null +++ b/src/next/example/scope2-b.tact @@ -0,0 +1 @@ +import "./scope2-d"; diff --git a/src/next/example/scope2-c.tact b/src/next/example/scope2-c.tact new file mode 100644 index 0000000000..0024bfb41a --- /dev/null +++ b/src/next/example/scope2-c.tact @@ -0,0 +1 @@ +import "./scope2-d"; diff --git a/src/next/example/scope2-d.tact b/src/next/example/scope2-d.tact new file mode 100644 index 0000000000..14f28127d3 --- /dev/null +++ b/src/next/example/scope2-d.tact @@ -0,0 +1 @@ +fun f(): Int { return 1; } \ No newline at end of file diff --git a/src/next/example/set.tact b/src/next/example/set.tact new file mode 100644 index 0000000000..eb7cd235be --- /dev/null +++ b/src/next/example/set.tact @@ -0,0 +1,25 @@ +struct Set { + m: map; +} + +extends mutates fun add(self: Set, key: K) { + self.m.set(key, true); +} + +extends fun exists(self: Set, key: K): Bool { + return self.m.exists(key); +} + +message Add { + key: uint8; +} + +contract Test { + state: Set; + receive(msg: Add) { + self.state.add(msg.key); + } + get fun exists(key: uint8): Bool { + return self.state.exists(key); + } +} diff --git a/src/next/example/union.tact b/src/next/example/union.tact new file mode 100644 index 0000000000..05bdef2665 --- /dev/null +++ b/src/next/example/union.tact @@ -0,0 +1,21 @@ +union Either { + Left { + $: uint1 = 0; + left: L; + } + Right { + $: uint1 = 1; + right: R; + } +} + +union Messages { + Foo { + $: uint32 = 0x12345678; + foo: uint4; + } + Bar { + $: uint32 = 0x87654321; + bar: uint8; + } +} diff --git a/src/next/example/wallet-v4.tact b/src/next/example/wallet-v4.tact new file mode 100644 index 0000000000..2587434e31 --- /dev/null +++ b/src/next/example/wallet-v4.tact @@ -0,0 +1,235 @@ +message(0x64737472) RemovePlugin { + queryId: Int as uint64; +} + +message(0x706c7567) PluginRequestFunds { + queryId: Int as uint64; + amount: Int as coins; + extra: Cell?; +} + +struct ExtRequest { + bundle: SignedBundle; + walletId: Int as int32; + validUntil: Int as uint32; + seqno: Int as uint32; + op: Int as uint8; + payload: Slice as remaining; +} + +struct RawMsg { + bits: Int as uint6 = 0x18; + receiver: Address; + amount: Int as coins; + extra: Cell?; + bits2: Int as uint106 = 0; // 4 + 4 + 64 + 32 + 1 + 1 + op: Int as uint32; + queryId: Int as uint64; +} + +struct RawMsgWithDeploy { + bits: Int as uint6 = 0x18; + receiver: Address; + amount: Int as coins; + bits2: Int as uint108 = 4 + 2 + 1; // 1 + 4 + 4 + 64 + 32 + 1 + 1 + 1 + stateInit: Cell; + body: Cell; +} + +struct ContractState { + seqno: Int as uint32; + walletId: Int as int32; + publicKey: Int as uint256; + extensions: map; +} + +// Exit codes +const LowBalance: Int = 80; +const Expired: Int = 36; +const SeqnoMismatch: Int = 33; +const WalletIdMismatch: Int = 34; +const SignatureMismatch: Int = 35; +const PluginWasNotDeleted: Int = 39; + +// Op +const PluginTakeFunds: Int = 0x706c7567 | 0x80000000; +const PluginRemove: Int = 0x64737472 | 0x80000000; +const AddPluginAction: Int = 0x6e6f7465; +const RemovePluginAction: Int = 0x64737472; + +contract WalletV4( + state: ContractState, +) { + receive(msg: PluginRequestFunds) { + let addr = sender(); // check gas for ctx + + if (!self.state.extensions.exists(addr)) { + return; + } + + throwUnless(LowBalance, myBalance() - context().value >= msg.amount); + + // NOTE: Here and later we use RawMsg with nativeSendMessage because + // in v4 wallet implementation message bodies are stored as slices in the same cell + // instead of separate cell with ref. Our send built-ins (message, send) doesn't support such serialization + nativeSendMessage( + RawMsg { + queryId: msg.queryId, + op: PluginTakeFunds, + extra: msg.extra, + amount: msg.amount, + receiver: addr, + }.toCell(), + 64, + ); + } + + receive(msg: RemovePlugin) { + let addr = sender(); // check gas for ctx + + if (!self.state.extensions.exists(addr)) { + return; + } + + let _ = self.state.extensions.del(addr); + + if (context().bounceable) { + nativeSendMessage( + RawMsg { + queryId: msg.queryId, + op: PluginRemove, + extra: null, + amount: 0, + receiver: addr, + }.toCell(), + 64, + ); + } + } + + external(msgSlice: Slice) { + let msg = ExtRequest.fromSlice(msgSlice); + throwIf(Expired, msg.validUntil < now()); + throwUnless(SeqnoMismatch, msg.seqno == self.state.seqno); + throwUnless(WalletIdMismatch, msg.walletId == self.state.walletId); + throwUnless(SignatureMismatch, msg.bundle.verifySignature(self.state.publicKey)); + + acceptMessage(); + self.state.seqno += 1; + setData(self.state.toCell()); + commit(); + + // simple transfer + if (msg.op == 0) { + let payload = msg.payload; + /* + foreach (ref in payload.refs) { + let mode = payload.loadUint(8); + nativeSendMessage(ref, mode); + } + */ + while (payload.refs() != 0) { + let mode = payload.loadUint(8); + nativeSendMessage(payload.loadRef(), mode); + } + return; + } + + // deploy and add plugin + if (msg.op == 1) { + let payload = msg.payload; + let wc = payload.loadUint(8); + let amount = payload.loadCoins(); + let stateInit = payload.loadRef(); + let body = payload.loadRef(); + + let addr = newAddress(wc, stateInit.hash()); + // cant use deploy here because of only basechain support + nativeSendMessage( + RawMsgWithDeploy { + stateInit, + body, + amount, + receiver: addr, + }.toCell(), + 3, + ); + + self.state.extensions.set(addr, true); + } else if (msg.op == 2) { + // add plugin + let payload = msg.payload; + + let wc = payload.loadUint(8); + let addrHash = payload.loadUint(256); + let addr = newAddress(wc, addrHash); + + let amount = payload.loadCoins(); + let queryId = payload.loadUint(64); + + self.state.extensions.set(addr, true); + + nativeSendMessage( + RawMsg { + queryId, + op: AddPluginAction, + extra: null, + amount, + receiver: addr, + }.toCell(), + 64, + ); + } else if (msg.op == 3) { + // remove plugin + let payload = msg.payload; + + let wc = payload.loadUint(8); + let addrHash = payload.loadUint(256); + let addr = newAddress(wc, addrHash); + + let amount = payload.loadCoins(); + let queryId = payload.loadUint(64); + + throwUnless(PluginWasNotDeleted, self.state.extensions.del(addr)); + + nativeSendMessage( + RawMsg { + queryId, + op: RemovePluginAction, + extra: null, + amount: amount, + receiver: addr, + }.toCell(), + 64, + ); + } + } + + receive(_: Slice) { + // Fallback + } + + get fun seqno(): Int { + return self.state.seqno; + } + + get fun get_subwallet_id(): Int { + return self.state.walletId; + } + + get fun get_public_key(): Int { + return self.state.publicKey; + } + + get fun is_plugin_installed(wc: Int, hash: Int): Bool { + return self.state.extensions.exists(newAddress(wc, hash)); + } + + // this is different from FunC version, awaiting unbounded tuple impl in Tact + // also we need to return it as map of instead of Address (skip first 4 bytes) + get fun get_plugin_list(): map { + return self.state.extensions; + } +} + +asm fun setData(data: Cell) { c4 POP } diff --git a/src/next/fs/cursor.ts b/src/next/fs/cursor.ts new file mode 100644 index 0000000000..0996a7cabe --- /dev/null +++ b/src/next/fs/cursor.ts @@ -0,0 +1,28 @@ +import type { RelativePath } from "@/next/fs/path"; + +/** + * Points to a node of a file system: directory or file + */ +export interface Cursor { + /** + * Move cursor by given relative path + */ + readonly focus: (path: RelativePath) => this; + + /** + * Read file under the cursor + */ + readonly read: () => Promise; + + /** + * Write to file under the cursor + */ + readonly write: (content: string | Blob) => Promise; + + /** + * Get full absolute path to a file or directory + * + * NB! Only to be used with `log.source()` + */ + readonly getAbsolutePathForLog: () => string; +} diff --git a/src/next/fs/errors.ts b/src/next/fs/errors.ts new file mode 100644 index 0000000000..eb66396057 --- /dev/null +++ b/src/next/fs/errors.ts @@ -0,0 +1,40 @@ +import type { Logger } from "@/error/logger-util"; + +export const FsErrors = (l: Logger) => { + const regular = { + ENOENT: (absPath: string) => { + return l.error(l.text`File not found: ${l.path(absPath)}`); + }, + EACCES: (absPath: string) => { + return l.error(l.text`Permission denied: ${l.path(absPath)}`); + }, + EISDIR: (absPath: string) => { + return l.error(l.text`Directory is not a file: ${l.path(absPath)}`); + }, + EMFILE: (absPath: string) => { + return l.error(l.text`Too many open files: ${l.path(absPath)}`); + }, + ENAMETOOLONG: (absPath: string) => { + return l.error(l.text`Filename too long: ${l.path(absPath)}`); + }, + ENOSPC: (absPath: string) => { + return l.error(l.text`No space left on device: ${l.path(absPath)}`); + }, + } as const; + return { + regular, + unexpected: (error: unknown) => { + throw error; + }, + outOfRoot: (absPath: string) => { + return l.error( + l.text`Outside of the root directory: ${l.path(absPath)}`, + ); + }, + readonly: (absPath: string) => { + return l.error(l.text`Filesystem is readonly: ${l.path(absPath)}`); + }, + }; +}; + +export type FsErrors = ReturnType; diff --git a/src/next/fs/index.ts b/src/next/fs/index.ts new file mode 100644 index 0000000000..ad805f398f --- /dev/null +++ b/src/next/fs/index.ts @@ -0,0 +1,5 @@ +export * from "@/next/fs/cursor"; +export * from "@/next/fs/path"; +export * from "@/next/fs/util"; +export * from "@/next/fs/memory-fs"; +export * from "@/next/fs/proxy-fs"; diff --git a/src/next/fs/memory-fs.ts b/src/next/fs/memory-fs.ts new file mode 100644 index 0000000000..a94fb9fa9c --- /dev/null +++ b/src/next/fs/memory-fs.ts @@ -0,0 +1,86 @@ +import { appendPath, asString, emptyPath } from "@/next/fs/util"; +import { FsErrors } from "@/next/fs/errors"; + +import type { RelativePath } from "@/next/fs/path"; +import type { Cursor } from "@/next/fs/cursor"; +import type { Logger } from "@/error/logger-util"; + +type Options = { + // FIXME: should we pass log here, or into functions? + readonly log: Logger; + + /** + * Files present in memory file system at creation time + */ + readonly files: Map; + + /** + * Path to the root, used only for logging + * + * Absolute paths do not make sense in memory FS, as + * it doesn't have the actual root + */ + readonly root: RelativePath; + + /** + * Whether it's possible to `write` into + */ + readonly isReadonly: boolean; +}; + +export const emptyFiles: Map = new Map(); + +/** + * Create in-memory file system + */ +export function createMemoryFs({ + log, + files, + root, + isReadonly, +}: Options): Cursor { + const errors = FsErrors(log); + + function builder(currPath: RelativePath): Cursor { + const getAbsolutePathForLog = () => { + return asString(appendPath(root, currPath)); + }; + return { + getAbsolutePathForLog, + focus: (path) => { + const newPath = appendPath(currPath, path); + if (newPath.stepsUp !== 0) { + errors.outOfRoot(getAbsolutePathForLog()); + } + return builder(newPath); + }, + read: async () => { + const fullPath = asString(appendPath(root, currPath)); + const blob = files.get(fullPath); + if (typeof blob === "undefined") { + errors.regular.ENOENT(getAbsolutePathForLog()); + return; + } + return new TextDecoder("utf-8").decode( + await blob.arrayBuffer(), + ); + }, + // eslint-disable-next-line @typescript-eslint/require-await + write: async (content) => { + if (isReadonly) { + errors.readonly(getAbsolutePathForLog()); + } + const fullPath = asString(appendPath(root, currPath)); + const blob = + typeof content === "string" + ? new Blob([content], { + type: "text/plain;charset=utf-8", + }) + : content; + files.set(fullPath, blob); + }, + }; + } + + return builder(emptyPath); +} diff --git a/src/next/fs/path.ts b/src/next/fs/path.ts new file mode 100644 index 0000000000..106d40a649 --- /dev/null +++ b/src/next/fs/path.ts @@ -0,0 +1,13 @@ +/** + * Safe relative path + */ +export type RelativePath = { + /** + * Number of "../" in front of path + */ + readonly stepsUp: number; + /** + * /-separated strings that go after optional ../ + */ + readonly segments: readonly string[]; +}; diff --git a/src/next/fs/proxy-fs.ts b/src/next/fs/proxy-fs.ts new file mode 100644 index 0000000000..a97d27d608 --- /dev/null +++ b/src/next/fs/proxy-fs.ts @@ -0,0 +1,93 @@ +import { mkdir, readFile, writeFile } from "fs/promises"; +import { dirname, isAbsolute, join } from "path"; + +import { appendPath, asString, emptyPath } from "@/next/fs/util"; +import { throwInternal } from "@/error/errors"; +import { FsErrors } from "@/next/fs/errors"; +import type { Cursor } from "@/next/fs/cursor"; +import type { RelativePath } from "@/next/fs/path"; +import type { Logger } from "@/error/logger-util"; + +const asRecord = (t: Record) => t; + +type Options = { + readonly log: Logger; + readonly root: string; + readonly isReadonly: boolean; +}; + +/** + * Create file system that proxies requests to real file system + */ +export function createProxyFs({ + log, + root, + isReadonly, +}: Options): Cursor { + const errors = FsErrors(log); + + function builder(currPath: RelativePath): Cursor { + const getAbsolutePathForLog = () => { + return join(root, asString(currPath)); + }; + + async function catchCommonFsErrors(cb: () => Promise) { + try { + return await cb(); + } catch (error) { + if (!(error instanceof Error) || !("code" in error)) { + return errors.unexpected(error); + } + const code = error.code; + if (typeof code !== "string") { + return errors.unexpected(error); + } + const handlers = asRecord(errors.regular); + const handler = handlers[code]; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (handler) { + handler(getAbsolutePathForLog()); + return; + } else { + return errors.unexpected(error); + } + } + } + + return { + getAbsolutePathForLog, + focus: (path) => { + const newPath = appendPath(currPath, path); + if (newPath.stepsUp !== 0) { + errors.outOfRoot(getAbsolutePathForLog()); + } + return builder(newPath); + }, + read: () => { + return catchCommonFsErrors(() => { + return readFile(join(root, asString(currPath)), "utf-8"); + }); + }, + write: async (content) => { + if (isReadonly) { + errors.readonly(getAbsolutePathForLog()); + } + await catchCommonFsErrors(async () => { + const fullPath = join(root, asString(currPath)); + await mkdir(dirname(fullPath), { recursive: true }); + const encodedContent = + typeof content === "string" + ? content + : Buffer.from(await content.arrayBuffer()); + await writeFile(fullPath, encodedContent); + }); + }, + }; + } + + if (!isAbsolute(root)) { + throwInternal("Cannot pass relative paths"); + } + + return builder(emptyPath); +} diff --git a/src/next/fs/util.ts b/src/next/fs/util.ts new file mode 100644 index 0000000000..fc6f84ab0e --- /dev/null +++ b/src/next/fs/util.ts @@ -0,0 +1,68 @@ +import { throwInternalCompilerError } from "@/error/errors"; +import { RelativePath } from "@/next/fs/path"; +import { repeat } from "@/utils/array"; + +/** + * Constructor for relative paths + */ +const RelativePath = ( + stepsUp: number, + segments: readonly string[], +): RelativePath => { + if (stepsUp < 0) { + throwInternalCompilerError("Negative number of ../ in path"); + } + const result: RelativePath = { + stepsUp, + segments: Object.freeze(segments), + }; + return Object.freeze(result); +}; + +/** + * Convert raw string with relative POSIX path into RelativePath + */ +export const fromString = (raw: string): RelativePath => { + return raw.split("/").map(parseSegment).reduce(appendPath, emptyPath); +}; + +/** + * Convert RelativePath to string. + */ +export const asString = ({ stepsUp, segments }: RelativePath): string => { + return [...repeat("..", stepsUp), ...segments].join("/"); +}; + +/** + * Empty path, equivalent to "." + */ +export const emptyPath = RelativePath(0, []); + +/** + * Parent path, equivalent to ".." + */ +export const parentPath = RelativePath(1, []); + +/** + * Combine two relative paths + */ +export const appendPath = ( + left: RelativePath, + right: RelativePath, +): RelativePath => { + const delta = right.stepsUp - left.segments.length; + return RelativePath(left.stepsUp + Math.max(0, delta), [ + ...left.segments.slice(0, Math.max(0, -delta)), + ...right.segments, + ]); +}; + +const parseSegment = (segment: string): RelativePath => { + if (segment === "..") { + return RelativePath(1, []); + } + if (segment === "." || segment === "") { + return emptyPath; + } + return RelativePath(0, [segment]); +}; diff --git a/src/next/grammar/errors.ts b/src/next/grammar/errors.ts new file mode 100644 index 0000000000..b5df4ab185 --- /dev/null +++ b/src/next/grammar/errors.ts @@ -0,0 +1,300 @@ +import type { SourceLogger } from "@/error/logger-util"; +import type { Range } from "@/error/range"; +import { ImportErrors } from "@/next/grammar/import-parser"; + +const attributeSchema = (name: string, l: SourceLogger) => ({ + duplicate: (attr: string) => (loc: Range) => { + return l.at(loc).error(l.text`Duplicate ${name} attribute "${attr}"`); + }, + notAbstract: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Abstract ${name} can only be declared inside traits and should have the abstract modifier`, + ); + }, + tooAbstract: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Non-abstract ${name} has abstract modifier`); + }, +}); + +export const SyntaxErrors = (l: SourceLogger) => ({ + constant: attributeSchema("constant", l), + function: attributeSchema("function", l), + imports: ImportErrors(l), + + topLevelConstantWithAttribute: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Module-level constants do not support attributes`); + }, + literalTooLong: () => (loc: Range) => { + return l.at(loc).error(l.text`Bitstring has more than 128 digits`); + }, + extraneousComma: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Empty parameter list should not have a dangling comma`, + ); + }, + duplicateField: (name: string) => (loc: Range) => { + return l + .at(loc) + .error(l.text`Duplicate field destructuring: "${name}"`); + }, + restShouldBeLast: () => (loc: Range) => { + return l.at(loc).error(l.text`Rest parameter should be last`); + }, + reservedVarPrefix: (prefix: string) => (loc: Range) => { + return l + .at(loc) + .error(l.text`Variable name cannot start with "${prefix}"`); + }, + notCallable: () => (loc: Range) => { + return l.at(loc).error(l.text`Expression is not callable`); + }, + noGenericMethods: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Cannot pass type arguments to generic method`); + }, + noBouncedWithoutArg: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`bounced() receiver should accept a Message, bounced or Slice`, + ); + }, + noBouncedWithString: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`bounced() receiver can only accept a Message, bounced or Slice`, + ); + }, + noConstantDecl: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Constant definition requires an initializer`); + }, + noFunctionDecl: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Only full function definitions are allowed here`); + }, + expected: (expects: ReadonlySet) => (loc: Range) => { + return l.at(loc).error(l.expected(expects)); + }, + invalidFuncId: () => (loc: Range) => { + return l.at(loc).error(l.text`Invalid FunC identifier`); + }, + reservedFuncId: () => (loc: Range) => { + return l.at(loc).error(l.text`Reserved FunC identifier`); + }, + numericFuncId: () => (loc: Range) => { + return l.at(loc).error(l.text`FunC identifier cannot be a number`); + }, + leadingZeroUnderscore: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Numbers with leading zeroes cannot use underscores for JS compatibility`, + ); + }, + asNotAllowed: () => (loc: Range) => { + return l.at(loc).error(l.text`"as" type is not allowed here`); + }, + multipleOptionals: () => (loc: Range) => { + return l.at(loc).error(l.text`Nested optional types are not allowed`); + }, + onlyOptionalOfNamed: () => (loc: Range) => { + return l.at(loc).error(l.text`Only named type can be optional`); + }, + genericArgCount: + (name: string, expectedCount: number, gotCount: number) => + (loc: Range) => { + return l + .at(loc) + .error( + l.text`${name}<> expects exactly ${String(expectedCount)} arguments, but got ${String(gotCount)}`, + ); + }, + unknownType: (name: string) => (loc: Range) => { + return l.at(loc).error(l.text`Unknown generic type: ${name}`); + }, + onlyBouncedOfNamed: () => (loc: Range) => { + return l.at(loc).error(l.text`Only named type can be bounced<>`); + }, + mapOnlyOneAs: (name: "key" | "value") => (loc: Range) => { + return l + .at(loc) + .error(l.text`Cannot use several "as" on ${name} of a map`); + }, + cannotBeOptional: (name: "key" | "value") => (loc: Range) => { + return l.at(loc).error(l.text`${name} cannot be optional`); + }, + onlyTypeId: (name: "key" | "value") => (loc: Range) => { + return l.at(loc).error(l.text`${name} can only be a named type`); + }, + fieldOnlyOneAs: () => (loc: Range) => { + return l.at(loc).error(l.text`Cannot use several "as" on a field type`); + }, + noOptionalFieldType: () => (loc: Range) => { + return l.at(loc).error(l.text`Field type cannot be optional`); + }, + fieldMustBeNamed: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Only named type can be a type of a field`); + }, + unknownGeneric: () => (loc: Range) => { + return l.at(loc).error(l.text`Unknown generic type`); + }, + noWildcard: () => (loc: Range) => { + return l.at(loc).error(l.text`Wildcard not allowed here`); + }, + undefinedUnicodeCodepoint: () => (loc: Range) => { + return l.at(loc).error(l.text`Undefined Unicode code-point`); + }, + unsupportedAsmFunctionInContracts: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Assembly functions are only allowed at the module level - outside contracts or traits`, + ); + }, + duplicateAs: () => (loc: Range) => { + return l.at(loc).error(l.text`"as" cannot be nested`); + }, + typeArity: (name: string, expected: number) => (loc: Range) => { + return l + .at(loc) + .error(l.text`${name}<> expects ${String(expected)} arguments`); + }, + wrongVarIntSize: () => (loc: Range) => { + return l.at(loc).error(l.text`Varint can only be 16 or 32 bits wide`); + }, + wrongUIntSize: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Unsigned integer must be 1 to 256 bits wide`); + }, + wrongIntSize: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Signed integer must be 1 to 257 bits wide`); + }, + wrongFormat: (name: string) => (loc: Range) => { + return l + .at(loc) + .error(l.text`${name} cannot be defined with this storage format`); + }, + wrongSliceSize: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Slice byte format must either be 32 or 64`); + }, + rawRemaining: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Remaining can only be used as storage type on Slice, cell, or Builder`, + ); + }, + cannotHaveFormat: () => (loc: Range) => { + return l.at(loc).error(l.text`This type cannot have format definition`); + }, + deprecatedPrimitiveDecl: () => (_loc: Range) => { + // FIXME: enable after src2 replaces src + // l.at(loc).warn(l.text`"primitive" type declaration are deprecated`); + }, + constDeclNoType: () => (loc: Range) => { + return l.at(loc).error(l.text`Constant declaration must have a type`); + }, + mapArgCount: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`map takes exactly two type arguments`); + }, + setArgCount: () => (loc: Range) => { + return l.at(loc).error(l.text`set takes exactly one type argument`); + }, + abstractVirtual: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`"abstract" and "virtual" attributes cannot be used at the same time`, + ); + }, + abstractOverride: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`"abstract" and "override" attributes cannot be used at the same time`, + ); + }, + globalGetter: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`"Getters must be defined within a contract"`); + }, + mutatesWithoutExtends: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Mutating functions must be extend functions`); + }, + extendsSelf: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Extend function must have first parameter named "self"`, + ); + }, + globalWithAttr: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Globally defined functions cannot have "abstract", "virtual", or "override" attributes`, + ); + }, + globalConstWithAttr: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Globally defined constants cannot have "abstract", "virtual", or "override" attributes`, + ); + }, + localExtends: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Only globally defined function can be an extension method`, + ); + }, + tooMuchInit: () => (loc: Range) => { + return l.at(loc).error(l.text`Init function was already defined`); + }, + initFnAndParams: () => (loc: Range) => { + return l + .at(loc) + .error( + l.text`Cannot define init() on a contract that has contract parameters`, + ); + }, + abstractWithBody: () => (loc: Range) => { + return l.at(loc).error(l.text`Abstract declaration cannot have a body`); + }, + noBodyNoAbstract: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Declaration without a body must be abstract`); + }, + mustBeGeneric: () => (loc: Range) => { + return l.at(loc).error(l.text`This type must be generic`); + }, +}); + +export type SyntaxErrors = ReturnType>; diff --git a/src/next/grammar/gen.sh b/src/next/grammar/gen.sh new file mode 100755 index 0000000000..a823230ecc --- /dev/null +++ b/src/next/grammar/gen.sh @@ -0,0 +1 @@ +pgen src/next/grammar/grammar.peggy -o src/next/grammar/grammar.ts diff --git a/src/next/grammar/grammar.peggy b/src/next/grammar/grammar.peggy new file mode 100644 index 0000000000..2c478fe82c --- /dev/null +++ b/src/next/grammar/grammar.peggy @@ -0,0 +1,441 @@ +Module = + imports:Import* + items:moduleItem*; + +Import = + keyword<"import"> + path:StringLiteral + ";"; + +moduleItem + = PrimitiveTypeDecl + / Function + / AsmFunction + / NativeFunctionDecl + / Constant + / StructDecl + / MessageDecl + / UnionDecl + / AliasDecl + / Contract + / Trait; + +contractItemDecl + = ContractInit + / Receiver + / Function + / AsmFunction + / Constant + / storageVar; + +traitItemDecl + = Receiver + / Function + / AsmFunction + / Constant + / storageVar; + +PrimitiveTypeDecl = + keyword<"primitive"> + name:TypeId + ";"; + +Function = + attributes:FunctionAttribute* + keyword<"fun"> + name:Id + typeParams:typeParams? + parameters:parameterList + returnType:ascription? + body:(FunctionDefinition / FunctionDeclaration); + +FunctionDefinition = body:statements; + +FunctionDeclaration = semicolon; + +AsmFunction = + "asm" + shuffle:shuffle? + attributes:FunctionAttribute* + keyword<"fun"> + name:Id + typeParams:typeParams? + parameters:parameterList + returnType:ascription? + "{" + instructions:assembly + "}"; + +shuffle = "(" ids:Id* to:("->" @IntegerLiteralDec+)? ")"; + +NativeFunctionDecl = + "@name" "(" + nativeName:#FuncId + ")" + attributes:FunctionAttribute* + keyword<"native"> + name:Id + typeParams:typeParams? + parameters:parameterList + returnType:ascription? + ";"; + +Constant = + attributes:ConstantAttribute* + keyword<"const"> + name:Id + type:ascription? + body:(ConstantDefinition / ConstantDeclaration); + +ConstantAttribute = name:( + keyword<"virtual"> + / keyword<"override"> + / keyword<"abstract"> +); + +ConstantDefinition = "=" expression:expression semicolon; + +ConstantDeclaration = semicolon; + +storageVar = @FieldDecl semicolon; + +StructDecl = + "struct" + name:TypeId + typeParams:typeParams? + "{" + fields:structFields + "}"; + +MessageDecl = + "message" + opcode:("(" @expression ")")? + name:TypeId + "{" + fields:structFields + "}"; + +UnionDecl = + "union" + name:TypeId + typeParams:typeParams? + "{" + cases:Case* + "}"; + +Case = + name:TypeId + "{" + fields:structFields + "}"; + +structFields = @inter? ";"?; + +AliasDecl = + "type" + name:TypeId + typeParams:typeParams? + "=" + type:type + ";"; + +FieldDecl = + name:Id + type:ascription + expression:("=" @expression)?; + +Contract = + attributes:ContractAttribute* + keyword<"contract"> + name:TypeId + parameters:ParameterList? + traits:inheritedTraits? + "{" + declarations:contractItemDecl* + "}"; + +Trait = + attributes:ContractAttribute* + keyword<"trait"> + name:TypeId + traits:inheritedTraits? + "{" + declarations:traitItemDecl* + "}"; + +inheritedTraits = keyword<"with"> @commaList; + +ContractInit = + "init" + parameters:parameterList + body:statements; + +ContractAttribute = "@interface" "(" name:StringLiteral ")"; + +// 'get' cannot be a reserved word because there is the map '.get' method +FunctionAttribute = name:( + GetAttribute + / keyword<"mutates"> + / keyword<"extends"> + / keyword<"virtual"> + / keyword<"override"> + / keyword<"inline"> + / keyword<"abstract"> +); + +GetAttribute = "get" methodId:("(" @expression ")")?; + +Receiver = type:ReceiverType "(" param:receiverParam ")" body:statements; +// "bounced" cannot be a reserved word because there a 'bounced' field in stdlib's 'Context' structure +ReceiverType = name:("bounced" / keyword<"receive"> / keyword<"external">); +receiverParam = @(Parameter / StringLiteral)?; + +assembly = #$assemblySequence; +assemblySequence = assemblyItem*; +assemblyItem + = "{" assemblySequence "}" + / comment + / "\"" [^"]* "\"" + / (!(["{}] / "//" / "/*") .)+; + +ascription = ":" @type; + +type = TypeAs; +TypeAs = type:TypeOptional as:(keyword<"as"> @#storage)*; +TypeOptional = type:typePrimary optionals:Optional*; +Optional = "?"; + +typePrimary + = TypeGeneric + / TypeRegular + / TypeStorage + / TypeTuple + / TypeTensor + / TypeUnit + / typeParens; +TypeRegular = child:TypeId; +TypeStorage = child:storage; +TypeGeneric = name:(MapKeyword / Bounced / TypeId) args:typeArgs; +TypeTuple = "[" types:commaList? "]"; +TypeTensor = "(" head:type tail:("," @type)+ ","? ")"; +TypeUnit = "(" ")"; +typeParens = "(" @type ")"; +MapKeyword = keyword<"map">; +Bounced = "bounced"; + +storage + = IntStorage + / CoinsStorage + / RemainingStorage + / BytesStorage; +IntStorage = + isVar:"var"? + isUnsigned: "u"? + "int" + width:$(digit+); +CoinsStorage = "coins"; +RemainingStorage = "remaining"; +BytesStorage = "bytes" width:$(digit+); + +TypeId "capitalized identifier" = name:#$([A-Z] [a-zA-Z0-9_]*); + +typeParams = generic; +typeArgs = generic; +generic = "<" @commaList? ">"; + +statement + = StatementLet + / StatementDestruct + / StatementBlock + / StatementReturn + / StatementCondition + / StatementWhile + / StatementRepeat + / StatementUntil + / StatementTry + / StatementForEach + / StatementExpression + / StatementAssign; + +statements = "{" @statement* "}"; + +StatementLet = keyword<"let"> name:Id type:ascription? "=" init:expression semicolon; +StatementDestruct = keyword<"let"> type:TypeId typeArgs:typeArgs? "{" fields:inter rest:optionalRest "}" "=" init:expression semicolon; +StatementBlock = body:statements; +StatementReturn = keyword<"return"> expression:expression? semicolon; +StatementExpression = expression:expression semicolon; +StatementAssign = left:expression operator:(augmentedOp / "=") right:expression semicolon; +StatementCondition = keyword<"if"> condition:expression trueBranch:statements falseBranch:(keyword<"else"> @(FalseBranch / StatementCondition))?; +StatementWhile = keyword<"while"> condition:parens body:statements; +StatementRepeat = keyword<"repeat"> condition:parens body:statements; +StatementUntil = keyword<"do"> body:statements keyword<"until"> condition:parens semicolon; +StatementTry = keyword<"try"> body:statements handler:(keyword<"catch"> "(" name:Id ")" body:statements)?; +StatementForEach = keyword<"foreach"> "(" key:Id "," value:Id "in" expression:expression ")" body:statements; + +augmentedOp = "||=" / "&&=" / ">>=" / "<<=" / "-=" / "+=" / "*=" / "/=" / "%=" / "|=" / "&=" / "^="; +FalseBranch = body:statements; +semicolon = ";" / &"}"; + +destructItem = RegularField / PunnedField; +RegularField = fieldName:Id ":" varName:Id; +PunnedField = name:Id; + +optionalRest = "," @RestArgument / NoRestArgument; +RestArgument = ".."; +NoRestArgument = ","?; + +expression = Conditional; + +Conditional = head:or tail:("?" thenBranch:or ":" elseBranch:Conditional)?; + +or = Binary; +and = Binary; +bitwiseOr = Binary; +bitwiseXor = Binary; +bitwiseAnd = Binary; +equality = Binary=" / ">")>; +bitwiseShift = Binary>")>; +add = Binary; +mul = Binary; + +Unary = prefixes:Operator<[-+!~]>* expression:Suffix; +Suffix = expression:primary suffixes:suffix*; + +Binary = exprs:inter>; +Operator = name:U; + +suffix + = SuffixUnboxNotNull + / SuffixCall + / SuffixFieldAccess; + +SuffixUnboxNotNull = "!!"; +SuffixCall = + typeArgs:typeArgs? + params:parameterList; +SuffixFieldAccess = "." name:Id; + +// Order is important +primary + = Unit + / Tensor + / Tuple + / Parens + / MapLiteral + / SetLiteral + / StructInstance + / StaticCall + / IntegerLiteral + / BoolLiteral + / InitOf + / CodeOf + / Null + / StringLiteral + / Id; + +Null = keyword<"null">; + +parens = "(" @expression ")"; +Parens = child:parens; + +Unit = "(" ")"; +Tensor = "(" head:expression tail:("," @expression)+ ","? ")"; +Tuple = "[" types:commaList? "]"; + +StaticCall = + type:TypeId + typeArgs:typeArgs? + "." + name:Id + args:parameterList; + +StructInstance = + type:TypeId + typeArgs:typeArgs? + "{" + fields:commaList? + "}"; +StructFieldInitializer = name:Id init:(":" @expression)?; + +MapLiteral = + keyword<"map"> + typeArgs:typeArgs + "{" + fields:commaList? + "}"; +mapField = key:expression ":" value:expression; + +SetLiteral = + "set" + typeArgs:typeArgs + "{" + fields:commaList? + "}"; + +InitOf = keyword<"initOf"> name:TypeId params:parameterList; +CodeOf = "codeOf" name:TypeId; + +ParameterList = "(" values:commaList? ")"; +parameterList = "(" @commaList? ")"; +Parameter = name:Id type:ascription; + +commaList = @inter ","?; + +// order is important +IntegerLiteral = value:(IntegerLiteralHex / IntegerLiteralBin / IntegerLiteralOct / IntegerLiteralDec); + +IntegerLiteralDec = digits:#underscored; +IntegerLiteralHex = digits:#("0" [xX] @underscored); +IntegerLiteralBin = digits:#("0" [bB] @underscored<[01]>); +IntegerLiteralOct = digits:#("0" [oO] @underscored<[0-7]>); +underscored = $(T ("_"? T)*); +digit "digit" = [0-9]; + +idPart "identifier character" = [a-zA-Z0-9_]; +Id "identifier" = name:#$(!reservedWord ([a-zA-Z_] idPart* / "$")); + +// FunC identifiers, where `FuncId` stands for FunC function identifier +// A plain identifier cannot be a number, a single underscore, an operator, a keyword or a compiler directive +// See: https://github.com/ton-blockchain/ton/blob/master/crypto/func/keywords.cpp + +FuncId "FunC identifier" = accessor:[.~]? id:$("`" [^`\r\n]+ "`" / [^ \t\r\n()[\],.;~]+); + +// Boolean literals +BoolLiteral = value:("true" / "false") !idPart; + +// String literals +StringLiteral = value:#("\"" @$([^"\\] / "\\" @escapeChar)* "\""); + +escapeChar + = [\\"nrtvbf] + / "u{" @$(hexDigit hexDigit? hexDigit? hexDigit? hexDigit? hexDigit?) "}" + / "u" @$(hexDigit hexDigit hexDigit hexDigit) + / "x" @$(hexDigit hexDigit); + +hexDigit "hexadecimal digit" = [0-9a-fA-F]; + +keyword = #(@T !idPart); + +// Order is important +reservedWord "reserved word" = keyword<( + // extend and public are reserved for legacy reasons + "extend" / "public" / + + "fun" / "let" / "return" / "receive" / "native" / "primitive" / "null" / + "if" / "else" / "while" / "repeat" / "do" / "until" / "try" / "catch" / + "foreach" / "as" / "map" / "mutates" / "extends" / "external" / "import" / + "with" / "trait" / "initOf" / "override" / "abstract" / "virtual" / + "inline" / "const" +)>; + +space "space" = [ \t\r\n] / comment; +comment = multiLineComment / singleLineComment; +multiLineComment = "/*" @$(!"*/" .)* "*/"; +singleLineComment = "//" @$[^\r\n]*; + +// This is not used in the Tact grammar but +// it is useful for imports resolution +JustImports = imports:Import* .*; + +inter = head:A tail:(op:B right:A)*; diff --git a/src/next/grammar/grammar.ts b/src/next/grammar/grammar.ts new file mode 100644 index 0000000000..c37d653f2b --- /dev/null +++ b/src/next/grammar/grammar.ts @@ -0,0 +1,2952 @@ +/* Generated. Do not edit. */ +/* eslint-disable @typescript-eslint/no-namespace */ +/* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/no-redundant-type-constituents */ +/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as $ from "@tonstudio/parser-runtime"; +export namespace $ast { + export type Module = $.Located<{ + readonly $: "Module"; + readonly imports: readonly Import[]; + readonly items: readonly moduleItem[]; + }>; + export type Import = $.Located<{ + readonly $: "Import"; + readonly path: StringLiteral; + }>; + export type PrimitiveTypeDecl = $.Located<{ + readonly $: "PrimitiveTypeDecl"; + readonly name: TypeId; + }>; + export type $Function = $.Located<{ + readonly $: "Function"; + readonly attributes: readonly FunctionAttribute[]; + readonly name: Id; + readonly typeParams: typeParams | undefined; + readonly parameters: parameterList; + readonly returnType: ascription | undefined; + readonly body: FunctionDefinition | FunctionDeclaration; + }>; + export type AsmFunction = $.Located<{ + readonly $: "AsmFunction"; + readonly shuffle: shuffle | undefined; + readonly attributes: readonly FunctionAttribute[]; + readonly name: Id; + readonly typeParams: typeParams | undefined; + readonly parameters: parameterList; + readonly returnType: ascription | undefined; + readonly instructions: assembly; + }>; + export type NativeFunctionDecl = $.Located<{ + readonly $: "NativeFunctionDecl"; + readonly nativeName: FuncId; + readonly attributes: readonly FunctionAttribute[]; + readonly name: Id; + readonly typeParams: typeParams | undefined; + readonly parameters: parameterList; + readonly returnType: ascription | undefined; + }>; + export type Constant = $.Located<{ + readonly $: "Constant"; + readonly attributes: readonly ConstantAttribute[]; + readonly name: Id; + readonly type: ascription | undefined; + readonly body: ConstantDefinition | ConstantDeclaration; + }>; + export type StructDecl = $.Located<{ + readonly $: "StructDecl"; + readonly name: TypeId; + readonly typeParams: typeParams | undefined; + readonly fields: structFields; + }>; + export type MessageDecl = $.Located<{ + readonly $: "MessageDecl"; + readonly opcode: expression | undefined; + readonly name: TypeId; + readonly fields: structFields; + }>; + export type UnionDecl = $.Located<{ + readonly $: "UnionDecl"; + readonly name: TypeId; + readonly typeParams: typeParams | undefined; + readonly cases: readonly Case[]; + }>; + export type AliasDecl = $.Located<{ + readonly $: "AliasDecl"; + readonly name: TypeId; + readonly typeParams: typeParams | undefined; + readonly type: $type; + }>; + export type Contract = $.Located<{ + readonly $: "Contract"; + readonly attributes: readonly ContractAttribute[]; + readonly name: TypeId; + readonly parameters: ParameterList | undefined; + readonly traits: inheritedTraits | undefined; + readonly declarations: readonly contractItemDecl[]; + }>; + export type Trait = $.Located<{ + readonly $: "Trait"; + readonly attributes: readonly ContractAttribute[]; + readonly name: TypeId; + readonly traits: inheritedTraits | undefined; + readonly declarations: readonly traitItemDecl[]; + }>; + export type moduleItem = + | PrimitiveTypeDecl + | $Function + | AsmFunction + | NativeFunctionDecl + | Constant + | StructDecl + | MessageDecl + | UnionDecl + | AliasDecl + | Contract + | Trait; + export type ContractInit = $.Located<{ + readonly $: "ContractInit"; + readonly parameters: parameterList; + readonly body: statements; + }>; + export type Receiver = $.Located<{ + readonly $: "Receiver"; + readonly type: ReceiverType; + readonly param: receiverParam; + readonly body: statements; + }>; + export type FieldDecl = $.Located<{ + readonly $: "FieldDecl"; + readonly name: Id; + readonly type: ascription; + readonly expression: expression | undefined; + }>; + export type semicolon = ";" | "}"; + export type storageVar = FieldDecl; + export type contractItemDecl = + | ContractInit + | Receiver + | $Function + | AsmFunction + | Constant + | storageVar; + export type traitItemDecl = + | Receiver + | $Function + | AsmFunction + | Constant + | storageVar; + export type FunctionDefinition = $.Located<{ + readonly $: "FunctionDefinition"; + readonly body: statements; + }>; + export type FunctionDeclaration = $.Located<{ + readonly $: "FunctionDeclaration"; + }>; + export type Id = $.Located<{ + readonly $: "Id"; + readonly name: string; + }>; + export type IntegerLiteralDec = $.Located<{ + readonly $: "IntegerLiteralDec"; + readonly digits: underscored; + }>; + export type shuffle = { + readonly ids: readonly Id[]; + readonly to: readonly IntegerLiteralDec[] | undefined; + }; + export type ConstantAttribute = $.Located<{ + readonly $: "ConstantAttribute"; + readonly name: + | keyword<"virtual"> + | keyword<"override"> + | keyword<"abstract">; + }>; + export type ConstantDefinition = $.Located<{ + readonly $: "ConstantDefinition"; + readonly expression: expression; + }>; + export type ConstantDeclaration = $.Located<{ + readonly $: "ConstantDeclaration"; + }>; + export type Case = $.Located<{ + readonly $: "Case"; + readonly name: TypeId; + readonly fields: structFields; + }>; + export type inter = { + readonly head: A; + readonly tail: readonly { + readonly op: B; + readonly right: A; + }[]; + }; + export type structFields = inter | undefined; + export type keyword = T; + export type commaList = inter; + export type TypeId = $.Located<{ + readonly $: "TypeId"; + readonly name: string; + }>; + export type inheritedTraits = commaList; + export type ContractAttribute = $.Located<{ + readonly $: "ContractAttribute"; + readonly name: StringLiteral; + }>; + export type FunctionAttribute = $.Located<{ + readonly $: "FunctionAttribute"; + readonly name: + | GetAttribute + | keyword<"mutates"> + | keyword<"extends"> + | keyword<"virtual"> + | keyword<"override"> + | keyword<"inline"> + | keyword<"abstract">; + }>; + export type GetAttribute = $.Located<{ + readonly $: "GetAttribute"; + readonly methodId: expression | undefined; + }>; + export type ReceiverType = $.Located<{ + readonly $: "ReceiverType"; + readonly name: "bounced" | keyword<"receive"> | keyword<"external">; + }>; + export type Parameter = $.Located<{ + readonly $: "Parameter"; + readonly name: Id; + readonly type: ascription; + }>; + export type StringLiteral = $.Located<{ + readonly $: "StringLiteral"; + readonly value: string; + }>; + export type receiverParam = Parameter | StringLiteral | undefined; + export type assembly = string; + export type multiLineComment = string; + export type singleLineComment = string; + export type comment = multiLineComment | singleLineComment; + export type assemblyItem = {} | comment | {} | readonly {}[]; + export type assemblySequence = readonly assemblyItem[]; + export type TypeAs = $.Located<{ + readonly $: "TypeAs"; + readonly type: TypeOptional; + readonly as: readonly storage[]; + }>; + export type $type = TypeAs; + export type ascription = $type; + export type TypeOptional = $.Located<{ + readonly $: "TypeOptional"; + readonly type: typePrimary; + readonly optionals: readonly Optional[]; + }>; + export type Optional = $.Located<{ + readonly $: "Optional"; + }>; + export type TypeGeneric = $.Located<{ + readonly $: "TypeGeneric"; + readonly name: MapKeyword | Bounced | TypeId; + readonly args: typeArgs; + }>; + export type TypeRegular = $.Located<{ + readonly $: "TypeRegular"; + readonly child: TypeId; + }>; + export type TypeStorage = $.Located<{ + readonly $: "TypeStorage"; + readonly child: storage; + }>; + export type TypeTuple = $.Located<{ + readonly $: "TypeTuple"; + readonly types: commaList<$type> | undefined; + }>; + export type TypeTensor = $.Located<{ + readonly $: "TypeTensor"; + readonly head: $type; + readonly tail: readonly $type[]; + }>; + export type TypeUnit = $.Located<{ + readonly $: "TypeUnit"; + }>; + export type typeParens = $type; + export type typePrimary = + | TypeGeneric + | TypeRegular + | TypeStorage + | TypeTuple + | TypeTensor + | TypeUnit + | typeParens; + export type MapKeyword = $.Located<{ + readonly $: "MapKeyword"; + }>; + export type Bounced = $.Located<{ + readonly $: "Bounced"; + }>; + export type IntStorage = $.Located<{ + readonly $: "IntStorage"; + readonly isVar: "var" | undefined; + readonly isUnsigned: "u" | undefined; + readonly width: string; + }>; + export type CoinsStorage = $.Located<{ + readonly $: "CoinsStorage"; + }>; + export type RemainingStorage = $.Located<{ + readonly $: "RemainingStorage"; + }>; + export type BytesStorage = $.Located<{ + readonly $: "BytesStorage"; + readonly width: string; + }>; + export type storage = + | IntStorage + | CoinsStorage + | RemainingStorage + | BytesStorage; + export type generic = commaList | undefined; + export type typeParams = generic; + export type typeArgs = generic<$type>; + export type StatementLet = $.Located<{ + readonly $: "StatementLet"; + readonly name: Id; + readonly type: ascription | undefined; + readonly init: expression; + }>; + export type StatementDestruct = $.Located<{ + readonly $: "StatementDestruct"; + readonly type: TypeId; + readonly typeArgs: typeArgs | undefined; + readonly fields: inter; + readonly rest: optionalRest; + readonly init: expression; + }>; + export type StatementBlock = $.Located<{ + readonly $: "StatementBlock"; + readonly body: statements; + }>; + export type StatementReturn = $.Located<{ + readonly $: "StatementReturn"; + readonly expression: expression | undefined; + }>; + export type StatementCondition = $.Located<{ + readonly $: "StatementCondition"; + readonly condition: expression; + readonly trueBranch: statements; + readonly falseBranch: FalseBranch | StatementCondition | undefined; + }>; + export type StatementWhile = $.Located<{ + readonly $: "StatementWhile"; + readonly condition: parens; + readonly body: statements; + }>; + export type StatementRepeat = $.Located<{ + readonly $: "StatementRepeat"; + readonly condition: parens; + readonly body: statements; + }>; + export type StatementUntil = $.Located<{ + readonly $: "StatementUntil"; + readonly body: statements; + readonly condition: parens; + }>; + export type StatementTry = $.Located<{ + readonly $: "StatementTry"; + readonly body: statements; + readonly handler: + | { + readonly name: Id; + readonly body: statements; + } + | undefined; + }>; + export type StatementForEach = $.Located<{ + readonly $: "StatementForEach"; + readonly key: Id; + readonly value: Id; + readonly expression: expression; + readonly body: statements; + }>; + export type StatementExpression = $.Located<{ + readonly $: "StatementExpression"; + readonly expression: expression; + }>; + export type StatementAssign = $.Located<{ + readonly $: "StatementAssign"; + readonly left: expression; + readonly operator: augmentedOp | "="; + readonly right: expression; + }>; + export type statement = + | StatementLet + | StatementDestruct + | StatementBlock + | StatementReturn + | StatementCondition + | StatementWhile + | StatementRepeat + | StatementUntil + | StatementTry + | StatementForEach + | StatementExpression + | StatementAssign; + export type statements = readonly statement[]; + export type augmentedOp = + | "||=" + | "&&=" + | ">>=" + | "<<=" + | "-=" + | "+=" + | "*=" + | "/=" + | "%=" + | "|=" + | "&=" + | "^="; + export type FalseBranch = $.Located<{ + readonly $: "FalseBranch"; + readonly body: statements; + }>; + export type RegularField = $.Located<{ + readonly $: "RegularField"; + readonly fieldName: Id; + readonly varName: Id; + }>; + export type PunnedField = $.Located<{ + readonly $: "PunnedField"; + readonly name: Id; + }>; + export type destructItem = RegularField | PunnedField; + export type RestArgument = $.Located<{ + readonly $: "RestArgument"; + }>; + export type NoRestArgument = $.Located<{ + readonly $: "NoRestArgument"; + }>; + export type optionalRest = RestArgument | NoRestArgument; + export type Conditional = $.Located<{ + readonly $: "Conditional"; + readonly head: or; + readonly tail: + | { + readonly thenBranch: or; + readonly elseBranch: Conditional; + } + | undefined; + }>; + export type expression = Conditional; + export type Binary = $.Located<{ + readonly $: "Binary"; + readonly exprs: inter>; + }>; + export type Unary = $.Located<{ + readonly $: "Unary"; + readonly prefixes: readonly Operator<"-" | "+" | "!" | "~">[]; + readonly expression: Suffix; + }>; + export type mul = Binary; + export type add = Binary; + export type bitwiseShift = Binary>">; + export type compare = Binary=" | ">">; + export type equality = Binary; + export type bitwiseXor = Binary; + export type bitwiseOr = Binary; + export type and = Binary; + export type or = Binary; + export type Suffix = $.Located<{ + readonly $: "Suffix"; + readonly expression: primary; + readonly suffixes: readonly suffix[]; + }>; + export type Operator = $.Located<{ + readonly $: "Operator"; + readonly name: U; + }>; + export type SuffixUnboxNotNull = $.Located<{ + readonly $: "SuffixUnboxNotNull"; + }>; + export type SuffixCall = $.Located<{ + readonly $: "SuffixCall"; + readonly typeArgs: typeArgs | undefined; + readonly params: parameterList; + }>; + export type SuffixFieldAccess = $.Located<{ + readonly $: "SuffixFieldAccess"; + readonly name: Id; + }>; + export type suffix = SuffixUnboxNotNull | SuffixCall | SuffixFieldAccess; + export type Unit = $.Located<{ + readonly $: "Unit"; + }>; + export type Tensor = $.Located<{ + readonly $: "Tensor"; + readonly head: expression; + readonly tail: readonly expression[]; + }>; + export type Tuple = $.Located<{ + readonly $: "Tuple"; + readonly types: commaList | undefined; + }>; + export type Parens = $.Located<{ + readonly $: "Parens"; + readonly child: parens; + }>; + export type MapLiteral = $.Located<{ + readonly $: "MapLiteral"; + readonly typeArgs: typeArgs; + readonly fields: commaList | undefined; + }>; + export type SetLiteral = $.Located<{ + readonly $: "SetLiteral"; + readonly typeArgs: typeArgs; + readonly fields: commaList | undefined; + }>; + export type StructInstance = $.Located<{ + readonly $: "StructInstance"; + readonly type: TypeId; + readonly typeArgs: typeArgs | undefined; + readonly fields: commaList | undefined; + }>; + export type StaticCall = $.Located<{ + readonly $: "StaticCall"; + readonly type: TypeId; + readonly typeArgs: typeArgs | undefined; + readonly name: Id; + readonly args: parameterList; + }>; + export type IntegerLiteral = $.Located<{ + readonly $: "IntegerLiteral"; + readonly value: + | IntegerLiteralHex + | IntegerLiteralBin + | IntegerLiteralOct + | IntegerLiteralDec; + }>; + export type BoolLiteral = $.Located<{ + readonly $: "BoolLiteral"; + readonly value: "true" | "false"; + }>; + export type InitOf = $.Located<{ + readonly $: "InitOf"; + readonly name: TypeId; + readonly params: parameterList; + }>; + export type CodeOf = $.Located<{ + readonly $: "CodeOf"; + readonly name: TypeId; + }>; + export type Null = $.Located<{ + readonly $: "Null"; + }>; + export type primary = + | Unit + | Tensor + | Tuple + | Parens + | MapLiteral + | SetLiteral + | StructInstance + | StaticCall + | IntegerLiteral + | BoolLiteral + | InitOf + | CodeOf + | Null + | StringLiteral + | Id; + export type parens = expression; + export type StructFieldInitializer = $.Located<{ + readonly $: "StructFieldInitializer"; + readonly name: Id; + readonly init: expression | undefined; + }>; + export type mapField = { + readonly key: expression; + readonly value: expression; + }; + export type ParameterList = $.Located<{ + readonly $: "ParameterList"; + readonly values: commaList | undefined; + }>; + export type parameterList = commaList | undefined; + export type IntegerLiteralHex = $.Located<{ + readonly $: "IntegerLiteralHex"; + readonly digits: underscored; + }>; + export type IntegerLiteralBin = $.Located<{ + readonly $: "IntegerLiteralBin"; + readonly digits: underscored<"0" | "1">; + }>; + export type IntegerLiteralOct = $.Located<{ + readonly $: "IntegerLiteralOct"; + readonly digits: underscored; + }>; + export type underscored = string; + export type digit = string; + export type idPart = string | string | string | "_"; + export type FuncId = $.Located<{ + readonly $: "FuncId"; + readonly accessor: "." | "~" | undefined; + readonly id: string; + }>; + export type hexDigit = string | string | string; + export type escapeChar = + | "\\" + | '"' + | "n" + | "r" + | "t" + | "v" + | "b" + | "f" + | string + | string + | string; + export type reservedWord = keyword< + | "extend" + | "public" + | "fun" + | "let" + | "return" + | "receive" + | "native" + | "primitive" + | "null" + | "if" + | "else" + | "while" + | "repeat" + | "do" + | "until" + | "try" + | "catch" + | "foreach" + | "as" + | "map" + | "mutates" + | "extends" + | "external" + | "import" + | "with" + | "trait" + | "initOf" + | "override" + | "abstract" + | "virtual" + | "inline" + | "const" + >; + export type space = " " | "\t" | "\r" | "\n" | comment; + export type JustImports = $.Located<{ + readonly $: "JustImports"; + readonly imports: readonly Import[]; + }>; +} +export const Module: $.Parser<$ast.Module> = $.loc( + $.field( + $.pure("Module"), + "$", + $.field( + $.star($.lazy(() => Import)), + "imports", + $.field($.star($.lazy(() => moduleItem)), "items", $.eps), + ), + ), +); +export const Import: $.Parser<$ast.Import> = $.loc( + $.field( + $.pure("Import"), + "$", + $.right( + $.lazy(() => keyword($.str("import"))), + $.field( + $.lazy(() => StringLiteral), + "path", + $.right($.str(";"), $.eps), + ), + ), + ), +); +export const PrimitiveTypeDecl: $.Parser<$ast.PrimitiveTypeDecl> = $.loc( + $.field( + $.pure("PrimitiveTypeDecl"), + "$", + $.right( + $.lazy(() => keyword($.str("primitive"))), + $.field( + $.lazy(() => TypeId), + "name", + $.right($.str(";"), $.eps), + ), + ), + ), +); +export const $Function: $.Parser<$ast.$Function> = $.loc( + $.field( + $.pure("Function"), + "$", + $.field( + $.star($.lazy(() => FunctionAttribute)), + "attributes", + $.right( + $.lazy(() => keyword($.str("fun"))), + $.field( + $.lazy(() => Id), + "name", + $.field( + $.opt($.lazy(() => typeParams)), + "typeParams", + $.field( + $.lazy(() => + parameterList($.lazy(() => Parameter)), + ), + "parameters", + $.field( + $.opt($.lazy(() => ascription)), + "returnType", + $.field( + $.alt( + $.lazy(() => FunctionDefinition), + $.lazy(() => FunctionDeclaration), + ), + "body", + $.eps, + ), + ), + ), + ), + ), + ), + ), + ), +); +export const AsmFunction: $.Parser<$ast.AsmFunction> = $.loc( + $.field( + $.pure("AsmFunction"), + "$", + $.right( + $.str("asm"), + $.field( + $.opt($.lazy(() => shuffle)), + "shuffle", + $.field( + $.star($.lazy(() => FunctionAttribute)), + "attributes", + $.right( + $.lazy(() => keyword($.str("fun"))), + $.field( + $.lazy(() => Id), + "name", + $.field( + $.opt($.lazy(() => typeParams)), + "typeParams", + $.field( + $.lazy(() => + parameterList($.lazy(() => Parameter)), + ), + "parameters", + $.field( + $.opt($.lazy(() => ascription)), + "returnType", + $.right( + $.str("{"), + $.field( + $.lazy(() => assembly), + "instructions", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const NativeFunctionDecl: $.Parser<$ast.NativeFunctionDecl> = $.loc( + $.field( + $.pure("NativeFunctionDecl"), + "$", + $.right( + $.str("@name"), + $.right( + $.str("("), + $.field( + $.lex($.lazy(() => FuncId)), + "nativeName", + $.right( + $.str(")"), + $.field( + $.star($.lazy(() => FunctionAttribute)), + "attributes", + $.right( + $.lazy(() => keyword($.str("native"))), + $.field( + $.lazy(() => Id), + "name", + $.field( + $.opt($.lazy(() => typeParams)), + "typeParams", + $.field( + $.lazy(() => + parameterList( + $.lazy(() => Parameter), + ), + ), + "parameters", + $.field( + $.opt($.lazy(() => ascription)), + "returnType", + $.right($.str(";"), $.eps), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const Constant: $.Parser<$ast.Constant> = $.loc( + $.field( + $.pure("Constant"), + "$", + $.field( + $.star($.lazy(() => ConstantAttribute)), + "attributes", + $.right( + $.lazy(() => keyword($.str("const"))), + $.field( + $.lazy(() => Id), + "name", + $.field( + $.opt($.lazy(() => ascription)), + "type", + $.field( + $.alt( + $.lazy(() => ConstantDefinition), + $.lazy(() => ConstantDeclaration), + ), + "body", + $.eps, + ), + ), + ), + ), + ), + ), +); +export const StructDecl: $.Parser<$ast.StructDecl> = $.loc( + $.field( + $.pure("StructDecl"), + "$", + $.right( + $.str("struct"), + $.field( + $.lazy(() => TypeId), + "name", + $.field( + $.opt($.lazy(() => typeParams)), + "typeParams", + $.right( + $.str("{"), + $.field( + $.lazy(() => structFields), + "fields", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), + ), +); +export const MessageDecl: $.Parser<$ast.MessageDecl> = $.loc( + $.field( + $.pure("MessageDecl"), + "$", + $.right( + $.str("message"), + $.field( + $.opt( + $.right( + $.str("("), + $.left( + $.lazy(() => expression), + $.str(")"), + ), + ), + ), + "opcode", + $.field( + $.lazy(() => TypeId), + "name", + $.right( + $.str("{"), + $.field( + $.lazy(() => structFields), + "fields", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), + ), +); +export const UnionDecl: $.Parser<$ast.UnionDecl> = $.loc( + $.field( + $.pure("UnionDecl"), + "$", + $.right( + $.str("union"), + $.field( + $.lazy(() => TypeId), + "name", + $.field( + $.opt($.lazy(() => typeParams)), + "typeParams", + $.right( + $.str("{"), + $.field( + $.star($.lazy(() => Case)), + "cases", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), + ), +); +export const AliasDecl: $.Parser<$ast.AliasDecl> = $.loc( + $.field( + $.pure("AliasDecl"), + "$", + $.right( + $.str("type"), + $.field( + $.lazy(() => TypeId), + "name", + $.field( + $.opt($.lazy(() => typeParams)), + "typeParams", + $.right( + $.str("="), + $.field( + $.lazy(() => $type), + "type", + $.right($.str(";"), $.eps), + ), + ), + ), + ), + ), + ), +); +export const Contract: $.Parser<$ast.Contract> = $.loc( + $.field( + $.pure("Contract"), + "$", + $.field( + $.star($.lazy(() => ContractAttribute)), + "attributes", + $.right( + $.lazy(() => keyword($.str("contract"))), + $.field( + $.lazy(() => TypeId), + "name", + $.field( + $.opt( + $.lazy(() => + ParameterList($.lazy(() => Parameter)), + ), + ), + "parameters", + $.field( + $.opt($.lazy(() => inheritedTraits)), + "traits", + $.right( + $.str("{"), + $.field( + $.star($.lazy(() => contractItemDecl)), + "declarations", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const Trait: $.Parser<$ast.Trait> = $.loc( + $.field( + $.pure("Trait"), + "$", + $.field( + $.star($.lazy(() => ContractAttribute)), + "attributes", + $.right( + $.lazy(() => keyword($.str("trait"))), + $.field( + $.lazy(() => TypeId), + "name", + $.field( + $.opt($.lazy(() => inheritedTraits)), + "traits", + $.right( + $.str("{"), + $.field( + $.star($.lazy(() => traitItemDecl)), + "declarations", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), + ), + ), +); +export const moduleItem: $.Parser<$ast.moduleItem> = $.alt( + PrimitiveTypeDecl, + $.alt( + $Function, + $.alt( + AsmFunction, + $.alt( + NativeFunctionDecl, + $.alt( + Constant, + $.alt( + StructDecl, + $.alt( + MessageDecl, + $.alt( + UnionDecl, + $.alt(AliasDecl, $.alt(Contract, Trait)), + ), + ), + ), + ), + ), + ), + ), +); +export const ContractInit: $.Parser<$ast.ContractInit> = $.loc( + $.field( + $.pure("ContractInit"), + "$", + $.right( + $.str("init"), + $.field( + $.lazy(() => parameterList($.lazy(() => Parameter))), + "parameters", + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), + ), + ), +); +export const Receiver: $.Parser<$ast.Receiver> = $.loc( + $.field( + $.pure("Receiver"), + "$", + $.field( + $.lazy(() => ReceiverType), + "type", + $.right( + $.str("("), + $.field( + $.lazy(() => receiverParam), + "param", + $.right( + $.str(")"), + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), + ), + ), + ), + ), +); +export const FieldDecl: $.Parser<$ast.FieldDecl> = $.loc( + $.field( + $.pure("FieldDecl"), + "$", + $.field( + $.lazy(() => Id), + "name", + $.field( + $.lazy(() => ascription), + "type", + $.field( + $.opt( + $.right( + $.str("="), + $.lazy(() => expression), + ), + ), + "expression", + $.eps, + ), + ), + ), + ), +); +export const semicolon: $.Parser<$ast.semicolon> = $.alt( + $.str(";"), + $.lookPos($.str("}")), +); +export const storageVar: $.Parser<$ast.storageVar> = $.left( + FieldDecl, + semicolon, +); +export const contractItemDecl: $.Parser<$ast.contractItemDecl> = $.alt( + ContractInit, + $.alt( + Receiver, + $.alt($Function, $.alt(AsmFunction, $.alt(Constant, storageVar))), + ), +); +export const traitItemDecl: $.Parser<$ast.traitItemDecl> = $.alt( + Receiver, + $.alt($Function, $.alt(AsmFunction, $.alt(Constant, storageVar))), +); +export const FunctionDefinition: $.Parser<$ast.FunctionDefinition> = $.loc( + $.field( + $.pure("FunctionDefinition"), + "$", + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), +); +export const FunctionDeclaration: $.Parser<$ast.FunctionDeclaration> = $.loc( + $.field($.pure("FunctionDeclaration"), "$", $.right(semicolon, $.eps)), +); +export const Id: $.Parser<$ast.Id> = $.named( + "identifier", + $.loc( + $.field( + $.pure("Id"), + "$", + $.field( + $.lex( + $.stry( + $.right( + $.lookNeg($.lazy(() => reservedWord)), + $.right( + $.alt( + $.right( + $.regex( + "a-zA-Z_", + [ + $.ExpRange("a", "z"), + $.ExpRange("A", "Z"), + $.ExpString("_"), + ], + ), + $.right( + $.star($.lazy(() => idPart)), + $.eps, + ), + ), + $.str("$"), + ), + $.eps, + ), + ), + ), + ), + "name", + $.eps, + ), + ), + ), +); +export const IntegerLiteralDec: $.Parser<$ast.IntegerLiteralDec> = $.loc( + $.field( + $.pure("IntegerLiteralDec"), + "$", + $.field( + $.lex($.lazy(() => underscored($.lazy(() => digit)))), + "digits", + $.eps, + ), + ), +); +export const shuffle: $.Parser<$ast.shuffle> = $.right( + $.str("("), + $.field( + $.star(Id), + "ids", + $.field( + $.opt($.right($.str("->"), $.plus(IntegerLiteralDec))), + "to", + $.right($.str(")"), $.eps), + ), + ), +); +export const ConstantAttribute: $.Parser<$ast.ConstantAttribute> = $.loc( + $.field( + $.pure("ConstantAttribute"), + "$", + $.field( + $.alt( + $.lazy(() => keyword($.str("virtual"))), + $.alt( + $.lazy(() => keyword($.str("override"))), + $.lazy(() => keyword($.str("abstract"))), + ), + ), + "name", + $.eps, + ), + ), +); +export const ConstantDefinition: $.Parser<$ast.ConstantDefinition> = $.loc( + $.field( + $.pure("ConstantDefinition"), + "$", + $.right( + $.str("="), + $.field( + $.lazy(() => expression), + "expression", + $.right(semicolon, $.eps), + ), + ), + ), +); +export const ConstantDeclaration: $.Parser<$ast.ConstantDeclaration> = $.loc( + $.field($.pure("ConstantDeclaration"), "$", $.right(semicolon, $.eps)), +); +export const Case: $.Parser<$ast.Case> = $.loc( + $.field( + $.pure("Case"), + "$", + $.field( + $.lazy(() => TypeId), + "name", + $.right( + $.str("{"), + $.field( + $.lazy(() => structFields), + "fields", + $.right($.str("}"), $.eps), + ), + ), + ), + ), +); +export const inter = ( + A: $.Parser, + B: $.Parser, +): $.Parser<$ast.inter> => + $.field( + $.lazy(() => A), + "head", + $.field( + $.star( + $.field( + $.lazy(() => B), + "op", + $.field( + $.lazy(() => A), + "right", + $.eps, + ), + ), + ), + "tail", + $.eps, + ), + ); +export const structFields: $.Parser<$ast.structFields> = $.left( + $.opt(inter(FieldDecl, $.str(";"))), + $.opt($.str(";")), +); +export const keyword = (T: $.Parser): $.Parser<$ast.keyword> => + $.lex( + $.left( + $.lazy(() => T), + $.lookNeg($.lazy(() => idPart)), + ), + ); +export const commaList = (T: $.Parser): $.Parser<$ast.commaList> => + $.left( + inter( + $.lazy(() => T), + $.str(","), + ), + $.opt($.str(",")), + ); +export const TypeId: $.Parser<$ast.TypeId> = $.named( + "capitalized identifier", + $.loc( + $.field( + $.pure("TypeId"), + "$", + $.field( + $.lex( + $.stry( + $.right( + $.regex("A-Z", [$.ExpRange("A", "Z")]), + $.right( + $.star( + $.regex( + "a-zA-Z0-9_", + [ + $.ExpRange("a", "z"), + $.ExpRange("A", "Z"), + $.ExpRange("0", "9"), + $.ExpString("_"), + ], + ), + ), + $.eps, + ), + ), + ), + ), + "name", + $.eps, + ), + ), + ), +); +export const inheritedTraits: $.Parser<$ast.inheritedTraits> = $.right( + keyword($.str("with")), + commaList(TypeId), +); +export const ContractAttribute: $.Parser<$ast.ContractAttribute> = $.loc( + $.field( + $.pure("ContractAttribute"), + "$", + $.right( + $.str("@interface"), + $.right( + $.str("("), + $.field( + $.lazy(() => StringLiteral), + "name", + $.right($.str(")"), $.eps), + ), + ), + ), + ), +); +export const FunctionAttribute: $.Parser<$ast.FunctionAttribute> = $.loc( + $.field( + $.pure("FunctionAttribute"), + "$", + $.field( + $.alt( + $.lazy(() => GetAttribute), + $.alt( + keyword($.str("mutates")), + $.alt( + keyword($.str("extends")), + $.alt( + keyword($.str("virtual")), + $.alt( + keyword($.str("override")), + $.alt( + keyword($.str("inline")), + keyword($.str("abstract")), + ), + ), + ), + ), + ), + ), + "name", + $.eps, + ), + ), +); +export const GetAttribute: $.Parser<$ast.GetAttribute> = $.loc( + $.field( + $.pure("GetAttribute"), + "$", + $.right( + $.str("get"), + $.field( + $.opt( + $.right( + $.str("("), + $.left( + $.lazy(() => expression), + $.str(")"), + ), + ), + ), + "methodId", + $.eps, + ), + ), + ), +); +export const ReceiverType: $.Parser<$ast.ReceiverType> = $.loc( + $.field( + $.pure("ReceiverType"), + "$", + $.field( + $.alt( + $.str("bounced"), + $.alt(keyword($.str("receive")), keyword($.str("external"))), + ), + "name", + $.eps, + ), + ), +); +export const Parameter: $.Parser<$ast.Parameter> = $.loc( + $.field( + $.pure("Parameter"), + "$", + $.field( + Id, + "name", + $.field( + $.lazy(() => ascription), + "type", + $.eps, + ), + ), + ), +); +export const StringLiteral: $.Parser<$ast.StringLiteral> = $.loc( + $.field( + $.pure("StringLiteral"), + "$", + $.field( + $.lex( + $.right( + $.str('"'), + $.left( + $.stry( + $.star( + $.alt( + $.regex<'"' | "\\">( + '^"\\\\', + $.negateExps([ + $.ExpString('"'), + $.ExpString("\\"), + ]), + ), + $.right( + $.str("\\"), + $.lazy(() => escapeChar), + ), + ), + ), + ), + $.str('"'), + ), + ), + ), + "value", + $.eps, + ), + ), +); +export const receiverParam: $.Parser<$ast.receiverParam> = $.opt( + $.alt(Parameter, StringLiteral), +); +export const assembly: $.Parser<$ast.assembly> = $.lex( + $.stry($.lazy(() => assemblySequence)), +); +export const multiLineComment: $.Parser<$ast.multiLineComment> = $.right( + $.str("/*"), + $.left( + $.stry($.star($.right($.lookNeg($.str("*/")), $.right($.any, $.eps)))), + $.str("*/"), + ), +); +export const singleLineComment: $.Parser<$ast.singleLineComment> = $.right( + $.str("//"), + $.stry( + $.star( + $.regex<"\r" | "\n">( + "^\\r\\n", + $.negateExps([$.ExpString("\r"), $.ExpString("\n")]), + ), + ), + ), +); +export const comment: $.Parser<$ast.comment> = $.alt( + multiLineComment, + singleLineComment, +); +export const assemblyItem: $.Parser<$ast.assemblyItem> = $.alt( + $.right( + $.str("{"), + $.right( + $.lazy(() => assemblySequence), + $.right($.str("}"), $.eps), + ), + ), + $.alt( + comment, + $.alt( + $.right( + $.str('"'), + $.right( + $.star( + $.regex<'"'>('^"', $.negateExps([$.ExpString('"')])), + ), + $.right($.str('"'), $.eps), + ), + ), + $.plus( + $.right( + $.lookNeg( + $.alt( + $.regex<'"' | "{" | "}">('"{}', [ + $.ExpString('"'), + $.ExpString("{"), + $.ExpString("}"), + ]), + $.alt($.str("//"), $.str("/*")), + ), + ), + $.right($.any, $.eps), + ), + ), + ), + ), +); +export const assemblySequence: $.Parser<$ast.assemblySequence> = + $.star(assemblyItem); +export const TypeAs: $.Parser<$ast.TypeAs> = $.loc( + $.field( + $.pure("TypeAs"), + "$", + $.field( + $.lazy(() => TypeOptional), + "type", + $.field( + $.star( + $.right(keyword($.str("as")), $.lex($.lazy(() => storage))), + ), + "as", + $.eps, + ), + ), + ), +); +export const $type: $.Parser<$ast.$type> = TypeAs; +export const ascription: $.Parser<$ast.ascription> = $.right($.str(":"), $type); +export const TypeOptional: $.Parser<$ast.TypeOptional> = $.loc( + $.field( + $.pure("TypeOptional"), + "$", + $.field( + $.lazy(() => typePrimary), + "type", + $.field($.star($.lazy(() => Optional)), "optionals", $.eps), + ), + ), +); +export const Optional: $.Parser<$ast.Optional> = $.loc( + $.field($.pure("Optional"), "$", $.right($.str("?"), $.eps)), +); +export const TypeGeneric: $.Parser<$ast.TypeGeneric> = $.loc( + $.field( + $.pure("TypeGeneric"), + "$", + $.field( + $.alt( + $.lazy(() => MapKeyword), + $.alt( + $.lazy(() => Bounced), + TypeId, + ), + ), + "name", + $.field( + $.lazy(() => typeArgs), + "args", + $.eps, + ), + ), + ), +); +export const TypeRegular: $.Parser<$ast.TypeRegular> = $.loc( + $.field($.pure("TypeRegular"), "$", $.field(TypeId, "child", $.eps)), +); +export const TypeStorage: $.Parser<$ast.TypeStorage> = $.loc( + $.field( + $.pure("TypeStorage"), + "$", + $.field( + $.lazy(() => storage), + "child", + $.eps, + ), + ), +); +export const TypeTuple: $.Parser<$ast.TypeTuple> = $.loc( + $.field( + $.pure("TypeTuple"), + "$", + $.right( + $.str("["), + $.field( + $.opt(commaList($type)), + "types", + $.right($.str("]"), $.eps), + ), + ), + ), +); +export const TypeTensor: $.Parser<$ast.TypeTensor> = $.loc( + $.field( + $.pure("TypeTensor"), + "$", + $.right( + $.str("("), + $.field( + $type, + "head", + $.field( + $.plus($.right($.str(","), $type)), + "tail", + $.right($.opt($.str(",")), $.right($.str(")"), $.eps)), + ), + ), + ), + ), +); +export const TypeUnit: $.Parser<$ast.TypeUnit> = $.loc( + $.field( + $.pure("TypeUnit"), + "$", + $.right($.right($.str("("), $.right($.str(")"), $.eps)), $.eps), + ), +); +export const typeParens: $.Parser<$ast.typeParens> = $.right( + $.str("("), + $.left($type, $.str(")")), +); +export const typePrimary: $.Parser<$ast.typePrimary> = $.alt( + TypeGeneric, + $.alt( + TypeRegular, + $.alt( + TypeStorage, + $.alt(TypeTuple, $.alt(TypeTensor, $.alt(TypeUnit, typeParens))), + ), + ), +); +export const MapKeyword: $.Parser<$ast.MapKeyword> = $.loc( + $.field($.pure("MapKeyword"), "$", $.right(keyword($.str("map")), $.eps)), +); +export const Bounced: $.Parser<$ast.Bounced> = $.loc( + $.field($.pure("Bounced"), "$", $.right($.str("bounced"), $.eps)), +); +export const IntStorage: $.Parser<$ast.IntStorage> = $.loc( + $.field( + $.pure("IntStorage"), + "$", + $.field( + $.opt($.str("var")), + "isVar", + $.field( + $.opt($.str("u")), + "isUnsigned", + $.right( + $.str("int"), + $.field( + $.stry($.plus($.lazy(() => digit))), + "width", + $.eps, + ), + ), + ), + ), + ), +); +export const CoinsStorage: $.Parser<$ast.CoinsStorage> = $.loc( + $.field($.pure("CoinsStorage"), "$", $.right($.str("coins"), $.eps)), +); +export const RemainingStorage: $.Parser<$ast.RemainingStorage> = $.loc( + $.field( + $.pure("RemainingStorage"), + "$", + $.right($.str("remaining"), $.eps), + ), +); +export const BytesStorage: $.Parser<$ast.BytesStorage> = $.loc( + $.field( + $.pure("BytesStorage"), + "$", + $.right( + $.str("bytes"), + $.field($.stry($.plus($.lazy(() => digit))), "width", $.eps), + ), + ), +); +export const storage: $.Parser<$ast.storage> = $.alt( + IntStorage, + $.alt(CoinsStorage, $.alt(RemainingStorage, BytesStorage)), +); +export const generic = (T: $.Parser): $.Parser<$ast.generic> => + $.right($.str("<"), $.left($.opt(commaList($.lazy(() => T))), $.str(">"))); +export const typeParams: $.Parser<$ast.typeParams> = generic(TypeId); +export const typeArgs: $.Parser<$ast.typeArgs> = generic($type); +export const StatementLet: $.Parser<$ast.StatementLet> = $.loc( + $.field( + $.pure("StatementLet"), + "$", + $.right( + keyword($.str("let")), + $.field( + Id, + "name", + $.field( + $.opt(ascription), + "type", + $.right( + $.str("="), + $.field( + $.lazy(() => expression), + "init", + $.right(semicolon, $.eps), + ), + ), + ), + ), + ), + ), +); +export const StatementDestruct: $.Parser<$ast.StatementDestruct> = $.loc( + $.field( + $.pure("StatementDestruct"), + "$", + $.right( + keyword($.str("let")), + $.field( + TypeId, + "type", + $.field( + $.opt(typeArgs), + "typeArgs", + $.right( + $.str("{"), + $.field( + inter( + $.lazy(() => destructItem), + $.str(","), + ), + "fields", + $.field( + $.lazy(() => optionalRest), + "rest", + $.right( + $.str("}"), + $.right( + $.str("="), + $.field( + $.lazy(() => expression), + "init", + $.right(semicolon, $.eps), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const StatementBlock: $.Parser<$ast.StatementBlock> = $.loc( + $.field( + $.pure("StatementBlock"), + "$", + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), +); +export const StatementReturn: $.Parser<$ast.StatementReturn> = $.loc( + $.field( + $.pure("StatementReturn"), + "$", + $.right( + keyword($.str("return")), + $.field( + $.opt($.lazy(() => expression)), + "expression", + $.right(semicolon, $.eps), + ), + ), + ), +); +export const StatementCondition: $.Parser<$ast.StatementCondition> = $.loc( + $.field( + $.pure("StatementCondition"), + "$", + $.right( + keyword($.str("if")), + $.field( + $.lazy(() => expression), + "condition", + $.field( + $.lazy(() => statements), + "trueBranch", + $.field( + $.opt( + $.right( + keyword($.str("else")), + $.alt( + $.lazy(() => FalseBranch), + $.lazy(() => StatementCondition), + ), + ), + ), + "falseBranch", + $.eps, + ), + ), + ), + ), + ), +); +export const StatementWhile: $.Parser<$ast.StatementWhile> = $.loc( + $.field( + $.pure("StatementWhile"), + "$", + $.right( + keyword($.str("while")), + $.field( + $.lazy(() => parens), + "condition", + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), + ), + ), +); +export const StatementRepeat: $.Parser<$ast.StatementRepeat> = $.loc( + $.field( + $.pure("StatementRepeat"), + "$", + $.right( + keyword($.str("repeat")), + $.field( + $.lazy(() => parens), + "condition", + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), + ), + ), +); +export const StatementUntil: $.Parser<$ast.StatementUntil> = $.loc( + $.field( + $.pure("StatementUntil"), + "$", + $.right( + keyword($.str("do")), + $.field( + $.lazy(() => statements), + "body", + $.right( + keyword($.str("until")), + $.field( + $.lazy(() => parens), + "condition", + $.right(semicolon, $.eps), + ), + ), + ), + ), + ), +); +export const StatementTry: $.Parser<$ast.StatementTry> = $.loc( + $.field( + $.pure("StatementTry"), + "$", + $.right( + keyword($.str("try")), + $.field( + $.lazy(() => statements), + "body", + $.field( + $.opt( + $.right( + keyword($.str("catch")), + $.right( + $.str("("), + $.field( + Id, + "name", + $.right( + $.str(")"), + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), + ), + ), + ), + ), + "handler", + $.eps, + ), + ), + ), + ), +); +export const StatementForEach: $.Parser<$ast.StatementForEach> = $.loc( + $.field( + $.pure("StatementForEach"), + "$", + $.right( + keyword($.str("foreach")), + $.right( + $.str("("), + $.field( + Id, + "key", + $.right( + $.str(","), + $.field( + Id, + "value", + $.right( + $.str("in"), + $.field( + $.lazy(() => expression), + "expression", + $.right( + $.str(")"), + $.field( + $.lazy(() => statements), + "body", + $.eps, + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const StatementExpression: $.Parser<$ast.StatementExpression> = $.loc( + $.field( + $.pure("StatementExpression"), + "$", + $.field( + $.lazy(() => expression), + "expression", + $.right(semicolon, $.eps), + ), + ), +); +export const StatementAssign: $.Parser<$ast.StatementAssign> = $.loc( + $.field( + $.pure("StatementAssign"), + "$", + $.field( + $.lazy(() => expression), + "left", + $.field( + $.alt( + $.lazy(() => augmentedOp), + $.str("="), + ), + "operator", + $.field( + $.lazy(() => expression), + "right", + $.right(semicolon, $.eps), + ), + ), + ), + ), +); +export const statement: $.Parser<$ast.statement> = $.alt( + StatementLet, + $.alt( + StatementDestruct, + $.alt( + StatementBlock, + $.alt( + StatementReturn, + $.alt( + StatementCondition, + $.alt( + StatementWhile, + $.alt( + StatementRepeat, + $.alt( + StatementUntil, + $.alt( + StatementTry, + $.alt( + StatementForEach, + $.alt( + StatementExpression, + StatementAssign, + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const statements: $.Parser<$ast.statements> = $.right( + $.str("{"), + $.left($.star(statement), $.str("}")), +); +export const augmentedOp: $.Parser<$ast.augmentedOp> = $.alt( + $.str("||="), + $.alt( + $.str("&&="), + $.alt( + $.str(">>="), + $.alt( + $.str("<<="), + $.alt( + $.str("-="), + $.alt( + $.str("+="), + $.alt( + $.str("*="), + $.alt( + $.str("/="), + $.alt( + $.str("%="), + $.alt( + $.str("|="), + $.alt($.str("&="), $.str("^=")), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const FalseBranch: $.Parser<$ast.FalseBranch> = $.loc( + $.field($.pure("FalseBranch"), "$", $.field(statements, "body", $.eps)), +); +export const RegularField: $.Parser<$ast.RegularField> = $.loc( + $.field( + $.pure("RegularField"), + "$", + $.field( + Id, + "fieldName", + $.right($.str(":"), $.field(Id, "varName", $.eps)), + ), + ), +); +export const PunnedField: $.Parser<$ast.PunnedField> = $.loc( + $.field($.pure("PunnedField"), "$", $.field(Id, "name", $.eps)), +); +export const destructItem: $.Parser<$ast.destructItem> = $.alt( + RegularField, + PunnedField, +); +export const RestArgument: $.Parser<$ast.RestArgument> = $.loc( + $.field($.pure("RestArgument"), "$", $.right($.str(".."), $.eps)), +); +export const NoRestArgument: $.Parser<$ast.NoRestArgument> = $.loc( + $.field($.pure("NoRestArgument"), "$", $.right($.opt($.str(",")), $.eps)), +); +export const optionalRest: $.Parser<$ast.optionalRest> = $.alt( + $.right($.str(","), RestArgument), + NoRestArgument, +); +export const Conditional: $.Parser<$ast.Conditional> = $.loc( + $.field( + $.pure("Conditional"), + "$", + $.field( + $.lazy(() => or), + "head", + $.field( + $.opt( + $.right( + $.str("?"), + $.field( + $.lazy(() => or), + "thenBranch", + $.right( + $.str(":"), + $.field( + $.lazy(() => Conditional), + "elseBranch", + $.eps, + ), + ), + ), + ), + ), + "tail", + $.eps, + ), + ), + ), +); +export const expression: $.Parser<$ast.expression> = Conditional; +export const Binary = ( + T: $.Parser, + U: $.Parser, +): $.Parser<$ast.Binary> => + $.loc( + $.field( + $.pure("Binary"), + "$", + $.field( + inter( + $.lazy(() => T), + $.lazy(() => Operator($.lazy(() => U))), + ), + "exprs", + $.eps, + ), + ), + ); +export const Unary: $.Parser<$ast.Unary> = $.loc( + $.field( + $.pure("Unary"), + "$", + $.field( + $.star( + $.lazy(() => + Operator( + $.regex<"-" | "+" | "!" | "~">("-+!~", [ + $.ExpString("-"), + $.ExpString("+"), + $.ExpString("!"), + $.ExpString("~"), + ]), + ), + ), + ), + "prefixes", + $.field( + $.lazy(() => Suffix), + "expression", + $.eps, + ), + ), + ), +); +export const mul: $.Parser<$ast.mul> = Binary( + Unary, + $.regex<"*" | "/" | "%">("*/%", [ + $.ExpString("*"), + $.ExpString("/"), + $.ExpString("%"), + ]), +); +export const add: $.Parser<$ast.add> = Binary( + mul, + $.alt($.str("+"), $.str("-")), +); +export const bitwiseShift: $.Parser<$ast.bitwiseShift> = Binary( + add, + $.alt($.str("<<"), $.str(">>")), +); +export const compare: $.Parser<$ast.compare> = Binary( + bitwiseShift, + $.alt($.str("<="), $.alt($.str("<"), $.alt($.str(">="), $.str(">")))), +); +export const equality: $.Parser<$ast.equality> = Binary( + compare, + $.alt($.str("!="), $.str("==")), +); +export const bitwiseAnd: $.Parser<$ast.bitwiseAnd> = Binary( + equality, + $.str("&"), +); +export const bitwiseXor: $.Parser<$ast.bitwiseXor> = Binary( + bitwiseAnd, + $.str("^"), +); +export const bitwiseOr: $.Parser<$ast.bitwiseOr> = Binary( + bitwiseXor, + $.str("|"), +); +export const and: $.Parser<$ast.and> = Binary(bitwiseOr, $.str("&&")); +export const or: $.Parser<$ast.or> = Binary(and, $.str("||")); +export const Suffix: $.Parser<$ast.Suffix> = $.loc( + $.field( + $.pure("Suffix"), + "$", + $.field( + $.lazy(() => primary), + "expression", + $.field($.star($.lazy(() => suffix)), "suffixes", $.eps), + ), + ), +); +export const Operator = (U: $.Parser): $.Parser<$ast.Operator> => + $.loc( + $.field( + $.pure("Operator"), + "$", + $.field( + $.lazy(() => U), + "name", + $.eps, + ), + ), + ); +export const SuffixUnboxNotNull: $.Parser<$ast.SuffixUnboxNotNull> = $.loc( + $.field($.pure("SuffixUnboxNotNull"), "$", $.right($.str("!!"), $.eps)), +); +export const SuffixCall: $.Parser<$ast.SuffixCall> = $.loc( + $.field( + $.pure("SuffixCall"), + "$", + $.field( + $.opt(typeArgs), + "typeArgs", + $.field( + $.lazy(() => parameterList(expression)), + "params", + $.eps, + ), + ), + ), +); +export const SuffixFieldAccess: $.Parser<$ast.SuffixFieldAccess> = $.loc( + $.field( + $.pure("SuffixFieldAccess"), + "$", + $.right($.str("."), $.field(Id, "name", $.eps)), + ), +); +export const suffix: $.Parser<$ast.suffix> = $.alt( + SuffixUnboxNotNull, + $.alt(SuffixCall, SuffixFieldAccess), +); +export const Unit: $.Parser<$ast.Unit> = $.loc( + $.field( + $.pure("Unit"), + "$", + $.right($.right($.str("("), $.right($.str(")"), $.eps)), $.eps), + ), +); +export const Tensor: $.Parser<$ast.Tensor> = $.loc( + $.field( + $.pure("Tensor"), + "$", + $.right( + $.str("("), + $.field( + expression, + "head", + $.field( + $.plus($.right($.str(","), expression)), + "tail", + $.right($.opt($.str(",")), $.right($.str(")"), $.eps)), + ), + ), + ), + ), +); +export const Tuple: $.Parser<$ast.Tuple> = $.loc( + $.field( + $.pure("Tuple"), + "$", + $.right( + $.str("["), + $.field( + $.opt(commaList(expression)), + "types", + $.right($.str("]"), $.eps), + ), + ), + ), +); +export const Parens: $.Parser<$ast.Parens> = $.loc( + $.field( + $.pure("Parens"), + "$", + $.field( + $.lazy(() => parens), + "child", + $.eps, + ), + ), +); +export const MapLiteral: $.Parser<$ast.MapLiteral> = $.loc( + $.field( + $.pure("MapLiteral"), + "$", + $.right( + keyword($.str("map")), + $.field( + typeArgs, + "typeArgs", + $.right( + $.str("{"), + $.field( + $.opt(commaList($.lazy(() => mapField))), + "fields", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), +); +export const SetLiteral: $.Parser<$ast.SetLiteral> = $.loc( + $.field( + $.pure("SetLiteral"), + "$", + $.right( + $.str("set"), + $.field( + typeArgs, + "typeArgs", + $.right( + $.str("{"), + $.field( + $.opt(commaList(expression)), + "fields", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), +); +export const StructInstance: $.Parser<$ast.StructInstance> = $.loc( + $.field( + $.pure("StructInstance"), + "$", + $.field( + TypeId, + "type", + $.field( + $.opt(typeArgs), + "typeArgs", + $.right( + $.str("{"), + $.field( + $.opt(commaList($.lazy(() => StructFieldInitializer))), + "fields", + $.right($.str("}"), $.eps), + ), + ), + ), + ), + ), +); +export const StaticCall: $.Parser<$ast.StaticCall> = $.loc( + $.field( + $.pure("StaticCall"), + "$", + $.field( + TypeId, + "type", + $.field( + $.opt(typeArgs), + "typeArgs", + $.right( + $.str("."), + $.field( + Id, + "name", + $.field( + $.lazy(() => parameterList(expression)), + "args", + $.eps, + ), + ), + ), + ), + ), + ), +); +export const IntegerLiteral: $.Parser<$ast.IntegerLiteral> = $.loc( + $.field( + $.pure("IntegerLiteral"), + "$", + $.field( + $.alt( + $.lazy(() => IntegerLiteralHex), + $.alt( + $.lazy(() => IntegerLiteralBin), + $.alt( + $.lazy(() => IntegerLiteralOct), + IntegerLiteralDec, + ), + ), + ), + "value", + $.eps, + ), + ), +); +export const BoolLiteral: $.Parser<$ast.BoolLiteral> = $.loc( + $.field( + $.pure("BoolLiteral"), + "$", + $.field( + $.alt($.str("true"), $.str("false")), + "value", + $.right($.lookNeg($.lazy(() => idPart)), $.eps), + ), + ), +); +export const InitOf: $.Parser<$ast.InitOf> = $.loc( + $.field( + $.pure("InitOf"), + "$", + $.right( + keyword($.str("initOf")), + $.field( + TypeId, + "name", + $.field( + $.lazy(() => parameterList(expression)), + "params", + $.eps, + ), + ), + ), + ), +); +export const CodeOf: $.Parser<$ast.CodeOf> = $.loc( + $.field( + $.pure("CodeOf"), + "$", + $.right($.str("codeOf"), $.field(TypeId, "name", $.eps)), + ), +); +export const Null: $.Parser<$ast.Null> = $.loc( + $.field($.pure("Null"), "$", $.right(keyword($.str("null")), $.eps)), +); +export const primary: $.Parser<$ast.primary> = $.alt( + Unit, + $.alt( + Tensor, + $.alt( + Tuple, + $.alt( + Parens, + $.alt( + MapLiteral, + $.alt( + SetLiteral, + $.alt( + StructInstance, + $.alt( + StaticCall, + $.alt( + IntegerLiteral, + $.alt( + BoolLiteral, + $.alt( + InitOf, + $.alt( + CodeOf, + $.alt( + Null, + $.alt(StringLiteral, Id), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const parens: $.Parser<$ast.parens> = $.right( + $.str("("), + $.left(expression, $.str(")")), +); +export const StructFieldInitializer: $.Parser<$ast.StructFieldInitializer> = + $.loc( + $.field( + $.pure("StructFieldInitializer"), + "$", + $.field( + Id, + "name", + $.field($.opt($.right($.str(":"), expression)), "init", $.eps), + ), + ), + ); +export const mapField: $.Parser<$ast.mapField> = $.field( + expression, + "key", + $.right($.str(":"), $.field(expression, "value", $.eps)), +); +export const ParameterList = ( + T: $.Parser, +): $.Parser<$ast.ParameterList> => + $.loc( + $.field( + $.pure("ParameterList"), + "$", + $.right( + $.str("("), + $.field( + $.opt(commaList($.lazy(() => T))), + "values", + $.right($.str(")"), $.eps), + ), + ), + ), + ); +export const parameterList = ( + T: $.Parser, +): $.Parser<$ast.parameterList> => + $.right($.str("("), $.left($.opt(commaList($.lazy(() => T))), $.str(")"))); +export const IntegerLiteralHex: $.Parser<$ast.IntegerLiteralHex> = $.loc( + $.field( + $.pure("IntegerLiteralHex"), + "$", + $.field( + $.lex( + $.right( + $.str("0"), + $.right( + $.regex<"x" | "X">("xX", [ + $.ExpString("x"), + $.ExpString("X"), + ]), + $.lazy(() => underscored($.lazy(() => hexDigit))), + ), + ), + ), + "digits", + $.eps, + ), + ), +); +export const IntegerLiteralBin: $.Parser<$ast.IntegerLiteralBin> = $.loc( + $.field( + $.pure("IntegerLiteralBin"), + "$", + $.field( + $.lex( + $.right( + $.str("0"), + $.right( + $.regex<"b" | "B">("bB", [ + $.ExpString("b"), + $.ExpString("B"), + ]), + $.lazy(() => + underscored( + $.regex<"0" | "1">("01", [ + $.ExpString("0"), + $.ExpString("1"), + ]), + ), + ), + ), + ), + ), + "digits", + $.eps, + ), + ), +); +export const IntegerLiteralOct: $.Parser<$ast.IntegerLiteralOct> = $.loc( + $.field( + $.pure("IntegerLiteralOct"), + "$", + $.field( + $.lex( + $.right( + $.str("0"), + $.right( + $.regex<"o" | "O">("oO", [ + $.ExpString("o"), + $.ExpString("O"), + ]), + $.lazy(() => + underscored( + $.regex("0-7", [$.ExpRange("0", "7")]), + ), + ), + ), + ), + ), + "digits", + $.eps, + ), + ), +); +export const underscored = (T: $.Parser): $.Parser<$ast.underscored> => + $.stry( + $.right( + $.lazy(() => T), + $.right( + $.star( + $.right( + $.opt($.str("_")), + $.right( + $.lazy(() => T), + $.eps, + ), + ), + ), + $.eps, + ), + ), + ); +export const digit: $.Parser<$ast.digit> = $.named( + "digit", + $.regex("0-9", [$.ExpRange("0", "9")]), +); +export const idPart: $.Parser<$ast.idPart> = $.named( + "identifier character", + $.regex("a-zA-Z0-9_", [ + $.ExpRange("a", "z"), + $.ExpRange("A", "Z"), + $.ExpRange("0", "9"), + $.ExpString("_"), + ]), +); +export const FuncId: $.Parser<$ast.FuncId> = $.named( + "FunC identifier", + $.loc( + $.field( + $.pure("FuncId"), + "$", + $.field( + $.opt( + $.regex<"." | "~">(".~", [ + $.ExpString("."), + $.ExpString("~"), + ]), + ), + "accessor", + $.field( + $.stry( + $.alt( + $.right( + $.str("`"), + $.right( + $.plus( + $.regex<"`" | "\r" | "\n">( + "^`\\r\\n", + $.negateExps([ + $.ExpString("`"), + $.ExpString("\r"), + $.ExpString("\n"), + ]), + ), + ), + $.right($.str("`"), $.eps), + ), + ), + $.plus( + $.regex< + | " " + | "\t" + | "\r" + | "\n" + | "(" + | ")" + | "[" + | string + | "," + | "." + | ";" + | "~" + >( + "^ \\t\\r\\n()[\\],.;~", + $.negateExps([ + $.ExpString(" "), + $.ExpString("\t"), + $.ExpString("\r"), + $.ExpString("\n"), + $.ExpString("("), + $.ExpString(")"), + $.ExpString("["), + $.ExpString('"\\]"'), + $.ExpString(","), + $.ExpString("."), + $.ExpString(";"), + $.ExpString("~"), + ]), + ), + ), + ), + ), + "id", + $.eps, + ), + ), + ), + ), +); +export const hexDigit: $.Parser<$ast.hexDigit> = $.named( + "hexadecimal digit", + $.regex("0-9a-fA-F", [ + $.ExpRange("0", "9"), + $.ExpRange("a", "f"), + $.ExpRange("A", "F"), + ]), +); +export const escapeChar: $.Parser<$ast.escapeChar> = $.alt( + $.regex<"\\" | '"' | "n" | "r" | "t" | "v" | "b" | "f">('\\\\"nrtvbf', [ + $.ExpString("\\"), + $.ExpString('"'), + $.ExpString("n"), + $.ExpString("r"), + $.ExpString("t"), + $.ExpString("v"), + $.ExpString("b"), + $.ExpString("f"), + ]), + $.alt( + $.right( + $.str("u{"), + $.left( + $.stry( + $.right( + hexDigit, + $.right( + $.opt(hexDigit), + $.right( + $.opt(hexDigit), + $.right( + $.opt(hexDigit), + $.right( + $.opt(hexDigit), + $.right($.opt(hexDigit), $.eps), + ), + ), + ), + ), + ), + ), + $.str("}"), + ), + ), + $.alt( + $.right( + $.str("u"), + $.stry( + $.right( + hexDigit, + $.right( + hexDigit, + $.right(hexDigit, $.right(hexDigit, $.eps)), + ), + ), + ), + ), + $.right( + $.str("x"), + $.stry($.right(hexDigit, $.right(hexDigit, $.eps))), + ), + ), + ), +); +export const reservedWord: $.Parser<$ast.reservedWord> = $.named( + "reserved word", + keyword( + $.alt( + $.str("extend"), + $.alt( + $.str("public"), + $.alt( + $.str("fun"), + $.alt( + $.str("let"), + $.alt( + $.str("return"), + $.alt( + $.str("receive"), + $.alt( + $.str("native"), + $.alt( + $.str("primitive"), + $.alt( + $.str("null"), + $.alt( + $.str("if"), + $.alt( + $.str("else"), + $.alt( + $.str("while"), + $.alt( + $.str("repeat"), + $.alt( + $.str("do"), + $.alt( + $.str( + "until", + ), + $.alt( + $.str( + "try", + ), + $.alt( + $.str( + "catch", + ), + $.alt( + $.str( + "foreach", + ), + $.alt( + $.str( + "as", + ), + $.alt( + $.str( + "map", + ), + $.alt( + $.str( + "mutates", + ), + $.alt( + $.str( + "extends", + ), + $.alt( + $.str( + "external", + ), + $.alt( + $.str( + "import", + ), + $.alt( + $.str( + "with", + ), + $.alt( + $.str( + "trait", + ), + $.alt( + $.str( + "initOf", + ), + $.alt( + $.str( + "override", + ), + $.alt( + $.str( + "abstract", + ), + $.alt( + $.str( + "virtual", + ), + $.alt( + $.str( + "inline", + ), + $.str( + "const", + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), + ), +); +export const space: $.Parser<$ast.space> = $.named( + "space", + $.alt( + $.regex<" " | "\t" | "\r" | "\n">(" \\t\\r\\n", [ + $.ExpString(" "), + $.ExpString("\t"), + $.ExpString("\r"), + $.ExpString("\n"), + ]), + comment, + ), +); +export const JustImports: $.Parser<$ast.JustImports> = $.loc( + $.field( + $.pure("JustImports"), + "$", + $.field($.star(Import), "imports", $.right($.star($.any), $.eps)), + ), +); diff --git a/src/next/grammar/import-parser.ts b/src/next/grammar/import-parser.ts new file mode 100644 index 0000000000..f92963fcec --- /dev/null +++ b/src/next/grammar/import-parser.ts @@ -0,0 +1,95 @@ +import type * as Ast from "@/next/ast"; +import { emptyPath, fromString } from "@/next/fs"; +import type { Language, Range } from "@/next/ast/common"; +import type { SourceLogger } from "@/error/logger-util"; + +const detectLanguage = (path: string): Language | undefined => { + if (path.endsWith(".fc") || path.endsWith(".func")) { + return "func"; + } + + if (path.endsWith(".tact")) { + return "tact"; + } + + return undefined; +}; + +const guessExtension = ( + importText: string, +): { language: Language; guessedPath: string } => { + const language = detectLanguage(importText); + if (language) { + return { guessedPath: importText, language }; + } else { + return { guessedPath: `${importText}.tact`, language: "tact" }; + } +}; + +const stdlibPrefix = "@stdlib/"; + +export const ImportErrors = (l: SourceLogger) => ({ + importWithBackslash: () => (loc: Range) => { + return l.at(loc).error(l.text`Import path can't contain "\\"`); + }, + noFolderImports: () => (loc: Range) => { + return l.at(loc).error(l.text`Cannot import a folder`); + }, + invalidImport: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Import must start with ./, ../ or @stdlib/`); + }, + escapingImport: () => (loc: Range) => { + return l + .at(loc) + .error(l.text`Standard library imports should be inside its root`); + }, +}); + +export type ImportErrors = ReturnType>; + +export function parseImportString( + importText: string, + range: Range, + err: ImportErrors, +): Ast.ImportPath { + if (importText.endsWith("/")) { + err.noFolderImports()(range); + importText = importText.slice(0, -1); + } + + if (importText.includes("\\")) { + err.importWithBackslash()(range); + importText = importText.replace(/\\/g, "/"); + } + + const { guessedPath, language } = guessExtension(importText); + + if (guessedPath.startsWith(stdlibPrefix)) { + const path = fromString(guessedPath.substring(stdlibPrefix.length)); + + if (path.stepsUp !== 0) { + err.importWithBackslash()(range); + } + + return { + path, + type: "stdlib", + language, + }; + } else if (guessedPath.startsWith("./") || guessedPath.startsWith("../")) { + return { + path: fromString(guessedPath), + type: "relative", + language, + }; + } else { + err.invalidImport()(range); + return { + path: emptyPath, + type: "relative", + language: "tact", + }; + } +} diff --git a/src/next/grammar/index.ts b/src/next/grammar/index.ts new file mode 100644 index 0000000000..cb7e0b2c7b --- /dev/null +++ b/src/next/grammar/index.ts @@ -0,0 +1,2027 @@ +import * as $ from "@tonstudio/parser-runtime"; +import * as Ast from "@/next/ast"; +import type { $ast } from "@/next/grammar/grammar"; +import * as G from "@/next/grammar/grammar"; +import { SyntaxErrors } from "@/next/grammar/errors"; +import { makeMakeVisitor } from "@/utils/tricks"; +import { throwInternal } from "@/error/errors"; +import type { SourceLogger } from "@/error/logger-util"; +import { parseImportString } from "@/next/grammar/import-parser"; +import { builtinTypes } from "@/next/types/builtins"; + +const makeVisitor = makeMakeVisitor("$"); + +const mergeRange = (left: Ast.Range, right: Ast.Range): Ast.Range => { + if (left.start > right.end) { + return throwInternal("Invalid range merge"); + } + if (left.path !== right.path) { + return throwInternal("Merging ranges from different sources"); + } + return Ast.Range(left.start, right.end, left.path, left.code); +}; + +type Context = { + readonly err: SyntaxErrors; + readonly toRange: (loc: $.Loc) => Ast.Range; +}; + +type Handler = (ctx: Context) => T; + +const map = + (ts: readonly T[], handler: (t: T) => Handler): Handler => + (ctx) => { + return ts.map((t) => handler(t)(ctx)); + }; + +const parseList = (node: $ast.inter | undefined): T[] => { + if (!node) { + return []; + } + const { head, tail } = node; + return [head, ...tail.map(({ right }) => right)]; +}; + +const parseId = + ({ name, loc }: $ast.Id | $ast.TypeId): Handler => + (ctx) => { + if (name.startsWith("__gen")) { + ctx.err.reservedVarPrefix("__gen")(ctx.toRange(loc)); + } + if (name.startsWith("__tact")) { + ctx.err.reservedVarPrefix("__tact")(ctx.toRange(loc)); + } + if (name === "_") { + ctx.err.noWildcard()(ctx.toRange(loc)); + } + return Ast.Id(name, ctx.toRange(loc)); + }; + +const parseOptionalId = + ({ name, loc }: $ast.Id | $ast.TypeId): Handler => + (ctx) => { + if (name.startsWith("__gen")) { + ctx.err.reservedVarPrefix("__gen")(ctx.toRange(loc)); + } + if (name.startsWith("__tact")) { + ctx.err.reservedVarPrefix("__tact")(ctx.toRange(loc)); + } + if (name === "_") { + return Ast.Wildcard(ctx.toRange(loc)); + } + return Ast.Id(name, ctx.toRange(loc)); + }; + +const parseVar = + ({ name, loc }: $ast.Id): Handler => + (ctx) => { + if (name.startsWith("__gen")) { + ctx.err.reservedVarPrefix("__gen")(ctx.toRange(loc)); + } + if (name.startsWith("__tact")) { + ctx.err.reservedVarPrefix("__tact")(ctx.toRange(loc)); + } + if (name === "_") { + ctx.err.noWildcard()(ctx.toRange(loc)); + } + return Ast.Var(name, ctx.toRange(loc)); + }; + +/* + FunC can parse much more than Fift can handle. For example, _0x0 and _0 are + valid identifiers in FunC, and using either of them compiles and is then + interpreted fine by Fift. But if you use both, FunC still compiles, but Fift crashes. + + Same goes for plain identifiers using hashes # or emojis — you can have one + FunC function with any of those combinations of characters, but you (generally) + cannot have two or more of such functions. +*/ +const reservedFuncIds: Set = new Set([ + "_", + "#include", + "#pragma", + "[", + "]", + "{", + "}", + "?", + ":", + "+", + "-", + "*", + "/%", + "/", + "%", + "~/", + "^/", + "~%", + "^%", + "<=>", + "<=", + "<", + ">=", + ">", + "!=", + "==", + "~>>", + "~", + "^>>", + "^", + "&", + "|", + "<<", + ">>", + "=", + "+=", + "-=", + "*=", + "/=", + "%=", + "~>>=", + "~/=", + "~%=", + "^>>=", + "^/=", + "^%=", + "^=", + "<<=", + ">>=", + "&=", + "|=", + "int", + "cell", + "builder", + "slice", + "cont", + "tuple", + "type", + "->", + "forall", + "return", + "var", + "repeat", + "do", + "while", + "until", + "try", + "catch", + "ifnot", + "if", + "then", + "elseifnot", + "elseif", + "else", + "extern", + "global", + "asm", + "impure", + "inline_ref", + "inline", + "auto_apply", + "method_id", + "operator", + "infixl", + "infixr", + "infix", + "const", +]); + +const parseFuncId = + ({ accessor, id, loc }: $ast.FuncId): Handler => + (ctx) => { + if (reservedFuncIds.has(id)) { + ctx.err.reservedFuncId()(ctx.toRange(loc)); + } + if (id.match(/^-?([0-9]+|0x[0-9a-fA-F]+)$/)) { + ctx.err.numericFuncId()(ctx.toRange(loc)); + } + if (id.startsWith('"') || id.startsWith("{-")) { + ctx.err.invalidFuncId()(ctx.toRange(loc)); + } + return Ast.FuncId((accessor ?? "") + id, ctx.toRange(loc)); + }; + +const baseMap = { + IntegerLiteralBin: "2", + IntegerLiteralOct: "8", + IntegerLiteralDec: "10", + IntegerLiteralHex: "16", +} as const; + +const prefixMap = { + IntegerLiteralBin: "0b", + IntegerLiteralOct: "0o", + IntegerLiteralDec: "", + IntegerLiteralHex: "0x", +} as const; + +const parseIntegerLiteralValue = + ({ $, digits, loc }: $ast.IntegerLiteral["value"]): Handler => + (ctx) => { + if ( + $ === "IntegerLiteralDec" && + digits.startsWith("0") && + digits.includes("_") + ) { + ctx.err.leadingZeroUnderscore()(ctx.toRange(loc)); + } + const value = BigInt(prefixMap[$] + digits.replaceAll("_", "")); + return Ast.Number(baseMap[$], value, ctx.toRange(loc)); + }; + +const parseIntegerLiteral = + ({ value }: $ast.IntegerLiteral): Handler => + (ctx) => { + return parseIntegerLiteralValue(value)(ctx); + }; + +const parseStringLiteral = + ({ value, loc }: $ast.StringLiteral): Handler => + (ctx) => { + const simplifiedValue = replaceEscapeSequences(value, loc, ctx); + return Ast.String(simplifiedValue, ctx.toRange(loc)); + }; + +export function replaceEscapeSequences( + stringLiteral: string, + loc: $.Loc, + ctx: Context, +): string { + return stringLiteral.replace( + /\\\\|\\"|\\n|\\r|\\t|\\v|\\b|\\f|\\u{([0-9A-Fa-f]{1,6})}|\\u([0-9A-Fa-f]{4})|\\x([0-9A-Fa-f]{2})/g, + (match, unicodeCodePoint, unicodeEscape, hexEscape) => { + switch (match) { + case "\\\\": + return "\\"; + case '\\"': + return '"'; + case "\\n": + return "\n"; + case "\\r": + return "\r"; + case "\\t": + return "\t"; + case "\\v": + return "\v"; + case "\\b": + return "\b"; + case "\\f": + return "\f"; + default: + // Handle Unicode code point escape + if (unicodeCodePoint) { + const codePoint = parseInt(unicodeCodePoint, 16); + if (codePoint > 0x10ffff) { + ctx.err.undefinedUnicodeCodepoint()( + ctx.toRange(loc), + ); + return match; + } + return String.fromCodePoint(codePoint); + } + // Handle Unicode escape + if (unicodeEscape) { + const codeUnit = parseInt(unicodeEscape, 16); + return String.fromCharCode(codeUnit); + } + // Handle hex escape + if (hexEscape) { + const hexValue = parseInt(hexEscape, 16); + return String.fromCharCode(hexValue); + } + return match; + } + }, + ); +} + +const parseBoolLiteral = + ({ value, loc }: $ast.BoolLiteral): Handler => + (ctx) => { + return Ast.Boolean(value === "true", ctx.toRange(loc)); + }; + +const parseNull = + ({ loc }: $ast.Null): Handler => + (ctx) => { + return Ast.Null(ctx.toRange(loc)); + }; + +const parseStructFieldInitializer = + ({ + name, + init, + loc, + }: $ast.StructFieldInitializer): Handler => + (ctx) => { + const fieldId = parseId(name)(ctx); + + // { x } + return Ast.StructFieldInitializer( + fieldId, + init ? parseExpression(init)(ctx) : parseVar(name)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStructInstance = + ({ + type, + typeArgs, + fields, + loc, + }: $ast.StructInstance): Handler => + (ctx) => { + return Ast.StructInstance( + parseTypeId(type)(ctx), + map(parseList(typeArgs), parseType)(ctx), + map(parseList(fields), parseStructFieldInitializer)(ctx), + ctx.toRange(loc), + ); + }; + +const parseBouncedArgs = + (typeArgs: $ast.typeArgs, range: Ast.Range): Handler => + (ctx) => { + const args = parseList(typeArgs); + const [head] = args; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (args.length !== 1 || !head) { + ctx.err.typeArity("bounced", 1)(range); + return Ast.TBounced( + Ast.TCons(Ast.TypeId("ERROR", range), [], range), + range, + ); + } + return Ast.TBounced(parseType(head)(ctx), range); + }; + +const parseMaybeArgs = + (typeArgs: $ast.typeArgs, range: Ast.Range): Handler => + (ctx) => { + const args = parseList(typeArgs); + const [head] = args; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (args.length !== 1 || !head) { + ctx.err.typeArity("Maybe", 1)(range); + return Ast.TMaybe( + Ast.TCons(Ast.TypeId("ERROR", range), [], range), + range, + ); + } + return Ast.TMaybe(parseType(head)(ctx), range); + }; + +const parseMapArgs = + (typeArgs: $ast.typeArgs, range: Ast.Range): Handler => + (ctx) => { + const args = parseList(typeArgs); + const [keyType, valueType] = args; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (args.length !== 2 || !keyType || !valueType) { + ctx.err.mapArgCount()(range); + return Ast.TMap( + Ast.TCons(Ast.TypeId("ERROR", range), [], range), + Ast.TCons(Ast.TypeId("ERROR", range), [], range), + range, + ); + } + return Ast.TMap( + parseType(keyType)(ctx), + parseType(valueType)(ctx), + range, + ); + }; + +const parseMapLiteral = + ({ typeArgs, fields, loc }: $ast.MapLiteral): Handler => + (ctx) => { + const range = ctx.toRange(loc); + return Ast.MapLiteral( + parseMapArgs(typeArgs, range)(ctx), + map(parseList(fields), parseMapField)(ctx), + range, + ); + }; + +const parseMapField = + ({ key, value }: $ast.mapField): Handler => + (ctx) => { + return Ast.MapField( + parseExpression(key)(ctx), + parseExpression(value)(ctx), + ); + }; + +const parseSetArgs = + (typeArgs: $ast.typeArgs, range: Ast.Range): Handler => + (ctx) => { + const args = parseList(typeArgs); + const [valueType] = args; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (args.length !== 1 || !valueType) { + ctx.err.setArgCount()(range); + return Ast.TMap( + Ast.TCons(Ast.TypeId("ERROR", range), [], range), + Ast.TBasic(Ast.TUnit(range), range), + range, + ); + } + return Ast.TMap( + parseType(valueType)(ctx), + Ast.TBasic(Ast.TUnit(range), range), + range, + ); + }; + +const parseSetLiteral = + ({ typeArgs, fields, loc }: $ast.SetLiteral): Handler => + (ctx) => { + const range = ctx.toRange(loc); + return Ast.SetLiteral( + parseSetArgs(typeArgs, range)(ctx), + map(parseList(fields), parseExpression)(ctx), + range, + ); + }; + +const parseInitOf = + ({ name, params, loc }: $ast.InitOf): Handler => + (ctx) => { + return Ast.InitOf( + parseTypeId(name)(ctx), + map(parseList(params), parseExpression)(ctx), + ctx.toRange(loc), + ); + }; + +const parseCodeOf = + ({ name, loc }: $ast.CodeOf): Handler => + (ctx) => { + return Ast.CodeOf(parseTypeId(name)(ctx), ctx.toRange(loc)); + }; + +const parseConditional = + ({ head, tail, loc }: $ast.Conditional): Handler => + (ctx) => { + const condition = parseExpression(head)(ctx); + if (!tail) { + return condition; + } + const { thenBranch, elseBranch } = tail; + return Ast.Conditional( + condition, + parseExpression(thenBranch)(ctx), + parseExpression(elseBranch)(ctx), + ctx.toRange(loc), + ); + }; + +const parseBinary = + ({ + exprs: { head, tail }, + }: $ast.Binary): Handler => + (ctx) => { + return tail.reduce( + ({ child, range }, { op, right }) => { + const merged = mergeRange( + range, + mergeRange(ctx.toRange(op.loc), ctx.toRange(right.loc)), + ); + return { + child: Ast.OpBinary( + op.name, + child, + parseExpression(right)(ctx), + merged, + ), + range: merged, + }; + }, + { child: parseExpression(head)(ctx), range: ctx.toRange(head.loc) }, + ).child; + }; + +const parseUnary = + ({ prefixes, expression }: $ast.Unary): Handler => + (ctx) => { + return prefixes.reduceRight( + ({ child, range }, { name, loc }) => { + const merged = mergeRange(ctx.toRange(loc), range); + return { + child: Ast.OpUnary(name, child, merged), + range: merged, + }; + }, + { + child: parseExpression(expression)(ctx), + range: ctx.toRange(expression.loc), + }, + ).child; + }; + +type SuffixHandler = Handler< + (child: Ast.Expression, loc: Ast.Range) => Ast.Expression +>; + +const parseSuffixUnboxNotNull = + (_: $ast.SuffixUnboxNotNull): SuffixHandler => + (_ctx) => + (child, loc) => { + return Ast.OpUnary("!!", child, loc); + }; + +const parseSuffixCall = + ({ params, typeArgs }: $ast.SuffixCall): SuffixHandler => + (ctx) => + (child, loc) => { + const paramsAst = map(parseList(params), parseExpression)(ctx); + if (child.kind === "var") { + return Ast.StaticCall( + Ast.Id(child.name, child.loc), + map(parseList(typeArgs), parseType)(ctx), + paramsAst, + loc, + ); + } else if (child.kind === "field_access") { + const parsedTypeArgs = map(parseList(typeArgs), parseType)(ctx); + if (parsedTypeArgs.length > 0) { + ctx.err.noGenericMethods()(loc); + } + return Ast.MethodCall( + child.aggregate, + child.field, + [], + paramsAst, + loc, + ); + } else { + ctx.err.notCallable()(loc); + return Ast.StaticCall( + Ast.Id("__invalid__", loc), + map(parseList(typeArgs), parseType)(ctx), + paramsAst, + loc, + ); + } + }; + +const parseSuffixFieldAccess = + ({ name }: $ast.SuffixFieldAccess): SuffixHandler => + (ctx) => + (child, loc) => { + return Ast.FieldAccess(child, parseId(name)(ctx), loc); + }; + +const suffixVisitor: (node: $ast.suffix) => SuffixHandler = + makeVisitor<$ast.suffix>()({ + SuffixUnboxNotNull: parseSuffixUnboxNotNull, + SuffixCall: parseSuffixCall, + SuffixFieldAccess: parseSuffixFieldAccess, + }); + +const parseSuffix = + ({ expression, suffixes }: $ast.Suffix): Handler => + (ctx) => { + return suffixes.reduce( + ({ child, range }, suffix) => { + const merged = mergeRange(range, ctx.toRange(suffix.loc)); + return { + child: suffixVisitor(suffix)(ctx)(child, merged), + range: merged, + }; + }, + { + child: parseExpression(expression)(ctx), + range: ctx.toRange(expression.loc), + }, + ).child; + }; + +const parseUnit = + ({ loc }: $ast.Unit): Handler => + (ctx) => { + return Ast.Unit(ctx.toRange(loc)); + }; + +const parseTensor = + ({ head, tail, loc }: $ast.Tensor): Handler => + (ctx) => { + return Ast.Tensor( + map([head, ...tail], parseExpression)(ctx), + ctx.toRange(loc), + ); + }; + +const parseTuple = + ({ types, loc }: $ast.Tuple): Handler => + (ctx) => { + return Ast.Tuple( + map(parseList(types), parseExpression)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStaticCall = + ({ + type, + name, + typeArgs, + args, + loc, + }: $ast.StaticCall): Handler => + (ctx) => { + return Ast.StaticMethodCall( + parseTypeId(type)(ctx), + map(parseList(typeArgs), parseType)(ctx), + parseId(name)(ctx), + map(parseList(args), parseExpression)(ctx), + ctx.toRange(loc), + ); + }; + +const parseParens = ({ child }: $ast.Parens): Handler => { + return parseExpression(child); +}; + +// has to be an interface because of the way TS handles circular type references +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +interface Binary extends $ast.Binary {} + +type Expression = + | $ast.Conditional + | Binary + | $ast.Unary + | $ast.Suffix + | $ast.Parens + | $ast.StructInstance + | $ast.IntegerLiteral + | $ast.BoolLiteral + | $ast.InitOf + | $ast.CodeOf + | $ast.Null + | $ast.StringLiteral + | $ast.Id + | $ast.Unit + | $ast.Tensor + | $ast.Tuple + | $ast.MapLiteral + | $ast.SetLiteral + | $ast.StaticCall; + +const parseExpression: (input: Expression) => Handler = + makeVisitor()({ + Conditional: parseConditional, + Binary: parseBinary, + Unary: parseUnary, + Suffix: parseSuffix, + Parens: parseParens, + StructInstance: parseStructInstance, + IntegerLiteral: parseIntegerLiteral, + BoolLiteral: parseBoolLiteral, + InitOf: parseInitOf, + CodeOf: parseCodeOf, + Null: parseNull, + StringLiteral: parseStringLiteral, + Id: parseVar, + Unit: parseUnit, + Tensor: parseTensor, + Tuple: parseTuple, + MapLiteral: parseMapLiteral, + SetLiteral: parseSetLiteral, + StaticCall: parseStaticCall, + }); + +const parseStatementLet = + ({ name, type, init, loc }: $ast.StatementLet): Handler => + (ctx) => { + return Ast.StatementLet( + parseOptionalId(name)(ctx), + type ? parseType(type)(ctx) : undefined, + parseExpression(init)(ctx), + ctx.toRange(loc), + ); + }; + +const parsePunnedField = + ({ name }: $ast.PunnedField): Handler<[Ast.Id, Ast.Id]> => + (ctx) => { + return [parseId(name)(ctx), parseId(name)(ctx)]; + }; + +const parseRegularField = + ({ + fieldName, + varName, + }: $ast.RegularField): Handler<[Ast.Id, Ast.OptionalId]> => + (ctx) => { + return [parseId(fieldName)(ctx), parseOptionalId(varName)(ctx)]; + }; + +const parseDestructItem: ( + node: $ast.destructItem, +) => Handler<[Ast.Id, Ast.OptionalId]> = makeVisitor<$ast.destructItem>()({ + PunnedField: parsePunnedField, + RegularField: parseRegularField, +}); + +const parseStatementDestruct = + ({ + type, + typeArgs, + fields, + rest, + init, + loc, + }: $ast.StatementDestruct): Handler => + (ctx) => { + const ids = map(parseList(fields), parseDestructItem)(ctx); + + return Ast.StatementDestruct( + parseTypeId(type)(ctx), + map(parseList(typeArgs), parseType)(ctx), + ids, + rest.$ === "RestArgument", + parseExpression(init)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStatementBlock = + ({ body, loc }: $ast.StatementBlock): Handler => + (ctx) => { + return Ast.StatementBlock(parseStatements(body)(ctx), ctx.toRange(loc)); + }; + +const parseStatementReturn = + ({ expression, loc }: $ast.StatementReturn): Handler => + (ctx) => { + return Ast.StatementReturn( + expression ? parseExpression(expression)(ctx) : undefined, + ctx.toRange(loc), + ); + }; + +const parseStatementCondition = + ({ + condition, + trueBranch, + falseBranch, + loc, + }: $ast.StatementCondition): Handler => + (ctx) => { + if (typeof falseBranch === "undefined") { + return Ast.StatementCondition( + parseExpression(condition)(ctx), + parseStatements(trueBranch)(ctx), + undefined, + ctx.toRange(loc), + ); + } else if (falseBranch.$ === "FalseBranch") { + return Ast.StatementCondition( + parseExpression(condition)(ctx), + parseStatements(trueBranch)(ctx), + parseStatements(falseBranch.body)(ctx), + ctx.toRange(loc), + ); + } else { + return Ast.StatementCondition( + parseExpression(condition)(ctx), + parseStatements(trueBranch)(ctx), + [parseStatementCondition(falseBranch)(ctx)], + ctx.toRange(loc), + ); + } + }; + +const parseStatementWhile = + ({ + condition, + body, + loc, + }: $ast.StatementWhile): Handler => + (ctx) => { + return Ast.StatementWhile( + parseExpression(condition)(ctx), + parseStatements(body)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStatementRepeat = + ({ + condition, + body, + loc, + }: $ast.StatementRepeat): Handler => + (ctx) => { + return Ast.StatementRepeat( + parseExpression(condition)(ctx), + parseStatements(body)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStatementUntil = + ({ + condition, + body, + loc, + }: $ast.StatementUntil): Handler => + (ctx) => { + return Ast.StatementUntil( + parseExpression(condition)(ctx), + parseStatements(body)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStatementTry = + ({ body, handler, loc }: $ast.StatementTry): Handler => + (ctx) => { + if (handler) { + return Ast.StatementTry( + parseStatements(body)(ctx), + { + name: parseOptionalId(handler.name)(ctx), + statements: parseStatements(handler.body)(ctx), + }, + ctx.toRange(loc), + ); + } else { + return Ast.StatementTry( + parseStatements(body)(ctx), + undefined, + ctx.toRange(loc), + ); + } + }; + +const parseStatementForEach = + ({ + key, + value, + expression, + body, + loc, + }: $ast.StatementForEach): Handler => + (ctx) => { + return Ast.StatementForEach( + parseOptionalId(key)(ctx), + parseOptionalId(value)(ctx), + parseExpression(expression)(ctx), + parseStatements(body)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStatementExpression = + ({ + expression, + loc, + }: $ast.StatementExpression): Handler => + (ctx) => { + return Ast.StatementExpression( + parseExpression(expression)(ctx), + ctx.toRange(loc), + ); + }; + +const parseStatementAssign = + ({ + left, + operator, + right, + loc, + }: $ast.StatementAssign): Handler< + Ast.StatementAssign | Ast.StatementAugmentedAssign + > => + (ctx) => { + if (operator === "=") { + return Ast.StatementAssign( + parseExpression(left)(ctx), + parseExpression(right)(ctx), + ctx.toRange(loc), + ); + } else { + return Ast.StatementAugmentedAssign( + operator, + parseExpression(left)(ctx), + parseExpression(right)(ctx), + ctx.toRange(loc), + ); + } + }; + +const parseStatement: (node: $ast.statement) => Handler = + makeVisitor<$ast.statement>()({ + StatementLet: parseStatementLet, + StatementDestruct: parseStatementDestruct, + StatementBlock: parseStatementBlock, + StatementReturn: parseStatementReturn, + StatementCondition: parseStatementCondition, + StatementWhile: parseStatementWhile, + StatementRepeat: parseStatementRepeat, + StatementUntil: parseStatementUntil, + StatementTry: parseStatementTry, + StatementForEach: parseStatementForEach, + StatementExpression: parseStatementExpression, + StatementAssign: parseStatementAssign, + }); + +const parseStatements = + (nodes: readonly $ast.statement[]): Handler => + (ctx) => { + return map(nodes, parseStatement)(ctx); + }; + +const parseGetAttribute = + ( + nodes: readonly $ast.FunctionAttribute[], + ): Handler => + (ctx) => { + const attrs: $ast.GetAttribute[] = []; + for (const node of nodes) { + if (typeof node.name === "object") { + attrs.push(node.name); + } + } + const [head, ...tail] = attrs; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (!head) { + return undefined; + } + for (const attr of tail) { + ctx.err.function.duplicate("get")(ctx.toRange(attr.loc)); + } + return Ast.GetAttribute( + head.methodId ? parseExpression(head.methodId)(ctx) : undefined, + ctx.toRange(head.loc), + ); + }; + +type NamedAttr = + | "mutates" + | "extends" + | "virtual" + | "override" + | "inline" + | "abstract"; + +const parseNamedAttr = + (key: K) => + ( + nodes: readonly ($ast.FunctionAttribute | $ast.ConstantAttribute)[], + ): Handler => + (ctx) => { + const attrs: Ast.Range[] = []; + for (const node of nodes) { + if (typeof node.name === "string" && node.name === key) { + attrs.push(ctx.toRange(node.loc)); + } + } + const [head, ...tail] = attrs; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (!head) { + return undefined; + } + for (const range of tail) { + ctx.err.function.duplicate(key)(range); + } + return head; + }; + +const parseParameter = + ({ name, type, loc }: $ast.Parameter): Handler => + (ctx) => { + return Ast.TypedParameter( + parseOptionalId(name)(ctx), + parseType(type)(ctx), + ctx.toRange(loc), + ); + }; + +const parseTypeId = + ({ name, loc }: $ast.TypeId): Handler => + (ctx) => { + return Ast.TypeId(name, ctx.toRange(loc)); + }; + +const parseTypeStorage = + ({ child: storage, loc }: $ast.TypeStorage): Handler => + (ctx) => { + const range = ctx.toRange(loc); + const fallback = Ast.TCons(Ast.TypeId("ERROR", range), [], range); + if (storage.$ === "CoinsStorage") { + return Ast.TBasic(Ast.TInt( + Ast.IFVarInt("unsigned", "16", ctx.toRange(storage.loc)), + range, + ), range); + } else if (storage.$ === "IntStorage") { + const width = parseInt(storage.width, 10); + if (storage.isVar) { + if (width === 16) { + return Ast.TBasic(Ast.TInt( + Ast.IFVarInt( + typeof storage.isUnsigned === "undefined" + ? "signed" + : "unsigned", + "16", + ctx.toRange(storage.loc), + ), + range, + ), range); + } else if (width === 32) { + return Ast.TBasic(Ast.TInt( + Ast.IFVarInt( + typeof storage.isUnsigned === "undefined" + ? "signed" + : "unsigned", + "32", + ctx.toRange(storage.loc), + ), + range, + ), range); + } else { + ctx.err.wrongVarIntSize()(range); + return fallback; + } + } else if (storage.isUnsigned) { + if (1 <= width && width <= 256) { + return Ast.TBasic(Ast.TInt( + Ast.IFInt("unsigned", width, range), + range, + ), range); + } else { + ctx.err.wrongUIntSize()(range); + return fallback; + } + } else { + if (1 <= width && width <= 257) { + return Ast.TBasic(Ast.TInt( + Ast.IFInt("signed", width, range), + range, + ), range); + } else { + ctx.err.wrongIntSize()(range); + return fallback; + } + } + } else if (storage.$ === "RemainingStorage") { + ctx.err.rawRemaining()(range); + return Ast.TBasic(Ast.TSlice(Ast.SFRemaining(range), range), range); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + } else if (storage.$ === "BytesStorage") { + const width = parseInt(storage.width, 10); + if (width === 32 || width === 64) { + return Ast.TBasic(Ast.TSlice(Ast.SFBits(width * 8, range), range), range); + } else { + ctx.err.wrongSliceSize()(range); + return fallback; + } + } else { + ctx.err.wrongFormat("No type")(range); + return fallback; + } + }; + +const applyFormat = + ( + type: Ast.Type, + storage: $ast.storage, + asLoc: Ast.Range, + ): Handler => + (ctx) => { + const fallback = Ast.TCons(Ast.TypeId("ERROR", asLoc), [], asLoc); + if (type.kind === "basic") { + const basic = applyBasic(type.type, storage, asLoc)(ctx); + return basic ? Ast.TBasic(basic, type.loc) : fallback; + } else if (type.kind === "cons_type" && type.name.text === "Maybe") { + // NB! Compatibility with old code that allowed `Int? as int32` + // instead of `(Int as int32)?` + const arg = type.typeArgs[0]; + if (type.typeArgs.length !== 1 || typeof arg === "undefined") { + return throwInternal("Maybe can only have one argument"); + } + const result = applyFormat(arg, storage, asLoc)(ctx); + return Ast.TCons(type.name, [result], type.loc); + } else { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (type.loc.kind !== "range") { + return throwInternal("Non-range in parser"); + } + ctx.err.cannotHaveFormat()(type.loc); + return fallback; + } + }; + +const applyBasic = ( + type: Ast.BasicType, + storage: $ast.storage, + asLoc: Ast.Range, +): Handler => +(ctx) => { + if (type.kind === "TyInt") { + if (storage.$ === "CoinsStorage") { + return Ast.TInt( + Ast.IFVarInt("unsigned", "16", ctx.toRange(storage.loc)), + type.loc, + ); + } else if (storage.$ === "IntStorage") { + const width = parseInt(storage.width, 10); + if (storage.isVar) { + if (width === 16) { + return Ast.TInt( + Ast.IFVarInt( + typeof storage.isUnsigned === "undefined" + ? "signed" + : "unsigned", + "16", + ctx.toRange(storage.loc), + ), + type.loc, + ); + } else if (width === 32) { + return Ast.TInt( + Ast.IFVarInt( + typeof storage.isUnsigned === "undefined" + ? "signed" + : "unsigned", + "32", + ctx.toRange(storage.loc), + ), + type.loc, + ); + } else { + ctx.err.wrongVarIntSize()(asLoc); + return undefined; + } + } else if (storage.isUnsigned) { + if (1 <= width && width <= 256) { + return Ast.TInt( + Ast.IFInt("unsigned", width, asLoc), + type.loc, + ); + } else { + ctx.err.wrongUIntSize()(asLoc); + return undefined; + } + } else { + if (1 <= width && width <= 257) { + return Ast.TInt( + Ast.IFInt("signed", width, asLoc), + type.loc, + ); + } else { + ctx.err.wrongIntSize()(asLoc); + return undefined; + } + } + } else { + ctx.err.wrongFormat("Integer")(asLoc); + return undefined; + } + } else if (type.kind === "TySlice") { + if (storage.$ === "RemainingStorage") { + return Ast.TSlice(Ast.SFRemaining(asLoc), type.loc); + } else if (storage.$ === "BytesStorage") { + const width = parseInt(storage.width, 10); + if (width === 32 || width === 64) { + return Ast.TSlice( + Ast.SFBits(width * 8, asLoc), + type.loc, + ); + } else { + ctx.err.wrongSliceSize()(asLoc); + return undefined; + } + } else { + ctx.err.wrongFormat("Slice")(asLoc); + return undefined; + } + } else if (type.kind === "TyCell" || type.kind === "TyBuilder") { + if (storage.$ === "RemainingStorage") { + const Type = + type.kind === "TyCell" ? Ast.TCell : Ast.TBuilder; + return Type(Ast.SFRemaining(asLoc), type.loc); + } else { + ctx.err.wrongFormat( + type.kind === "TyCell" ? "Cell" : "Builder", + )(asLoc); + return undefined; + } + } else { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (type.loc.kind !== "range") { + return throwInternal("Non-range in parser"); + } + ctx.err.cannotHaveFormat()(type.loc); + return undefined; + } +}; + +const parseTypeAs = + ({ type, as, loc }: $ast.TypeAs): Handler => + (ctx) => { + const onlyAs = as[0]; + if (as.length === 0 || typeof onlyAs === "undefined") { + return parseType(type)(ctx); + } + if (as.length > 1) { + ctx.err.duplicateAs()(ctx.toRange(loc)); + return Ast.TCons( + Ast.TypeId("ERROR", ctx.toRange(loc)), + [], + ctx.toRange(loc), + ); + } + const asLoc = ctx.toRange(loc); + const result = parseType(type)(ctx); + return applyFormat(result, onlyAs, asLoc)(ctx); + }; + +const parseTypeGeneric = + ({ name, args, loc }: $ast.TypeGeneric): Handler => + (ctx) => { + const range = ctx.toRange(loc); + if (name.$ === "Bounced") { + return parseBouncedArgs(args, range)(ctx); + } else if (name.$ === "MapKeyword" || name.name === "Map") { + return parseMapArgs(args, range)(ctx); + } else if (name.name === "Maybe") { + return parseMaybeArgs(args, range)(ctx); + } else if (builtinTypes.has(name.name)) { + ctx.err.typeArity(name.name, 0)(range); + return Ast.TCons(Ast.TypeId("ERROR", range), [], range); + } else { + return Ast.TCons( + Ast.TypeId(name.name, ctx.toRange(name.loc)), + map(parseList(args), parseTypeAs)(ctx), + range, + ); + } + }; + +const parseTypeOptional = + ({ type, optionals }: $ast.TypeOptional): Handler => + (ctx) => { + return optionals.reduce((acc, optional) => { + return Ast.TMaybe(acc, ctx.toRange(optional.loc)); + }, parseType(type)(ctx)); + }; + +const parseTypeRegular = + ({ child }: $ast.TypeRegular): Handler => + (ctx) => { + const range = ctx.toRange(child.loc); + switch (child.name) { + case "Int": + return Ast.TBasic(Ast.TInt(Ast.IFInt("signed", 257, range), range), range); + case "Slice": + return Ast.TBasic(Ast.TSlice(Ast.SFDefault(range), range), range); + case "Cell": + return Ast.TBasic(Ast.TCell(Ast.SFDefault(range), range), range); + case "Builder": + return Ast.TBasic(Ast.TBuilder(Ast.SFDefault(range), range), range); + case "Void": + return Ast.TBasic(Ast.TVoid(range), range); + case "Null": + return Ast.TBasic(Ast.TNull(range), range); + case "Bool": + return Ast.TBasic(Ast.TBool(range), range); + case "Address": + return Ast.TBasic(Ast.TAddress(range), range); + case "String": + return Ast.TBasic(Ast.TString(range), range); + case "StringBuilder": + return Ast.TBasic(Ast.TStringBuilder(range), range); + case "StateInit": + return Ast.TBasic(Ast.TStateInit(range), range); + case "Bounced": + ctx.err.mustBeGeneric()(range); + return Ast.TCons(Ast.TypeId("ERROR", range), [], range); + case "Maybe": + ctx.err.mustBeGeneric()(range); + return Ast.TCons(Ast.TypeId("ERROR", range), [], range); + default: + return Ast.TCons(parseTypeId(child)(ctx), [], range); + } + }; + +const parseTypeTensor = + ({ head, tail, loc }: $ast.TypeTensor): Handler => + (ctx) => { + return Ast.TTensor( + map([head, ...tail], parseType)(ctx), + ctx.toRange(loc), + ); + }; + +const parseTypeTuple = + ({ types, loc }: $ast.TypeTuple): Handler => + (ctx) => { + return Ast.TTuple( + map(parseList(types), parseType)(ctx), + ctx.toRange(loc), + ); + }; + +const parseTypeUnit = + ({ loc }: $ast.TypeUnit): Handler => + (ctx) => { + const range = ctx.toRange(loc); + return Ast.TBasic(Ast.TUnit(range), range); + }; + +type RawType = + | $ast.TypeAs + | $ast.TypeGeneric + | $ast.TypeRegular + | $ast.TypeOptional + | $ast.TypeTensor + | $ast.TypeUnit + | $ast.TypeTuple + | $ast.TypeStorage; + +const parseType: (node: RawType) => Handler = makeVisitor()({ + TypeAs: parseTypeAs, + TypeGeneric: parseTypeGeneric, + TypeOptional: parseTypeOptional, + TypeRegular: parseTypeRegular, + TypeTensor: parseTypeTensor, + TypeTuple: parseTypeTuple, + TypeUnit: parseTypeUnit, + TypeStorage: parseTypeStorage, +}); + +const parseFieldDecl = + ({ name, type, expression, loc }: $ast.FieldDecl): Handler => + (ctx) => { + return Ast.FieldDecl( + parseId(name)(ctx), + parseType(type)(ctx), + expression ? parseExpression(expression)(ctx) : undefined, + ctx.toRange(loc), + ); + }; + +const parseReceiverParam = + (param: $ast.receiverParam): Handler => + (ctx) => { + return !param + ? Ast.ReceiverFallback() + : param.$ === "Parameter" + ? Ast.ReceiverSimple(parseParameter(param)(ctx)) + : Ast.ReceiverComment(parseStringLiteral(param)(ctx)); + }; + +const parseReceiverInternal = + ({ type, param, body, loc }: $ast.Receiver): Handler => + (ctx) => { + return Ast.Receiver( + Ast.ReceiverInternal( + parseReceiverParam(param)(ctx), + ctx.toRange(type.loc), + ), + map(body, parseStatement)(ctx), + ctx.toRange(loc), + ); + }; + +const parseReceiverExternal = + ({ type, param, body, loc }: $ast.Receiver): Handler => + (ctx) => { + return Ast.Receiver( + Ast.ReceiverExternal( + parseReceiverParam(param)(ctx), + ctx.toRange(type.loc), + ), + map(body, parseStatement)(ctx), + ctx.toRange(loc), + ); + }; + +const emptyLoc = { $: "range", start: 0, end: 0 } as const; +const repairParam: $ast.receiverParam = { + $: "Parameter", + name: { + $: "Id", + name: "__invalid__", + loc: emptyLoc, + }, + type: { + $: "TypeAs", + as: [], + type: { + $: "TypeOptional", + optionals: [], + type: { + $: "TypeRegular", + child: { + $: "TypeId", + name: "__Invalid__", + loc: emptyLoc, + }, + loc: emptyLoc, + }, + loc: emptyLoc, + }, + loc: emptyLoc, + }, + loc: emptyLoc, +}; + +const parseReceiverBounced = + ({ type, param, body, loc }: $ast.Receiver): Handler => + (ctx) => { + if (typeof param === "undefined") { + ctx.err.noBouncedWithoutArg()(ctx.toRange(loc)); + param = repairParam; + } + + if (param.$ === "StringLiteral") { + ctx.err.noBouncedWithString()(ctx.toRange(loc)); + param = repairParam; + } + + return Ast.Receiver( + Ast.ReceiverBounce( + parseParameter(param)(ctx), + ctx.toRange(type.loc), + ), + map(body, parseStatement)(ctx), + ctx.toRange(loc), + ); + }; + +const parserByReceiverType: Record< + $ast.ReceiverType["name"], + (node: $ast.Receiver) => Handler +> = { + bounced: parseReceiverBounced, + receive: parseReceiverInternal, + external: parseReceiverExternal, +}; + +const parseReceiver = (node: $ast.Receiver): Handler => { + return parserByReceiverType[node.type.name](node); +}; + +const defaultShuffle = { + args: [], + ret: [], +}; + +const parseAsmShuffle = + (node: $ast.shuffle | undefined): Handler => + (ctx) => { + if (!node) { + return defaultShuffle; + } + + return { + args: map(node.ids, parseId)(ctx), + ret: node.to ? map(node.to, parseIntegerLiteralValue)(ctx) : [], + }; + }; + +const parseAsmFunctionRaw = + (node: $ast.AsmFunction): Handler => + (ctx) => { + const range = ctx.toRange(node.loc); + return Ast.Function( + !!parseNamedAttr("inline")(node.attributes)(ctx), + parseId(node.name)(ctx), + Ast.TFunction( + map(parseList(node.typeParams), parseTypeId)(ctx), + map(parseList(node.parameters), parseParameter)(ctx), + node.returnType + ? parseType(node.returnType)(ctx) + : Ast.TBasic(Ast.TVoid(range), range), + ), + Ast.AsmBody(parseAsmShuffle(node.shuffle)(ctx), [ + node.instructions.trim(), + ]), + range, + ); + }; + +const checkNoGlobalAttrs = + ( + attrs: readonly ($ast.FunctionAttribute | $ast.ConstantAttribute)[], + range: Ast.Range, + ): Handler => + (ctx) => { + const isVirtual = parseNamedAttr("virtual")(attrs)(ctx); + const isOverride = parseNamedAttr("override")(attrs)(ctx); + const isAbstract = parseNamedAttr("abstract")(attrs)(ctx); + if (isVirtual || isOverride || isAbstract) { + ctx.err.globalWithAttr()(range); + } + }; + +const parseInheritance = + ( + hasBody: boolean, + attrs: readonly ($ast.FunctionAttribute | $ast.ConstantAttribute)[], + range: Ast.Range, + ): Handler<{ override: boolean; overridable: boolean }> => + (ctx) => { + const isVirtual = parseNamedAttr("virtual")(attrs)(ctx); + const isOverride = parseNamedAttr("override")(attrs)(ctx); + const isAbstract = parseNamedAttr("abstract")(attrs)(ctx); + if (isAbstract) { + if (isVirtual) { + ctx.err.abstractVirtual()(isVirtual); + } + if (isOverride) { + ctx.err.abstractOverride()(isOverride); + } + if (hasBody) { + ctx.err.abstractWithBody()(isAbstract); + } + } else { + if (!hasBody) { + ctx.err.noBodyNoAbstract()(range); + } + } + return { + override: !!isOverride, + overridable: !!isVirtual || !!isAbstract, + }; + }; + +const parseConstant = + (node: $ast.Constant): Handler => + (ctx) => { + const name = parseId(node.name)(ctx); + const range = ctx.toRange(node.loc); + const type = (() => { + if (node.body.$ === "ConstantDefinition") { + return Ast.ConstantDef( + node.type ? parseType(node.type)(ctx) : undefined, + parseExpression(node.body.expression)(ctx), + ); + } else if (node.type) { + return Ast.ConstantDecl(parseType(node.type)(ctx)); + } else { + ctx.err.constDeclNoType()(range); + return Ast.ConstantDecl( + Ast.TCons(Ast.TypeId("ERROR", range), [], range), + ); + } + })(); + return Ast.Constant(name, type, range); + }; + +const parseConstantGlobal = + (node: $ast.Constant): Handler => + (ctx) => { + checkNoGlobalAttrs(node.attributes, ctx.toRange(node.loc))(ctx); + return parseConstant(node)(ctx); + }; + +const parseFieldConstant = + (node: $ast.Constant): Handler => + (ctx) => { + const body = parseConstant(node)(ctx); + const inh = parseInheritance( + body.init.kind === "constant_def", + node.attributes, + ctx.toRange(node.loc), + )(ctx); + return Ast.FieldConstant(inh.overridable, inh.override, body); + }; + +const parseContract = + ({ + name, + attributes, + parameters, + traits, + declarations, + loc, + }: $ast.Contract): Handler => + (ctx) => { + const params = parseList<$ast.Parameter>(parameters?.values).map( + (param) => { + return parseFieldDecl({ + $: "FieldDecl", + name: param.name, + type: param.type, + expression: undefined, + loc: param.loc, + })(ctx); + }, + ); + + const initFns: $ast.ContractInit[] = []; + const locals: $ast.traitItemDecl[] = []; + for (const decl of declarations) { + if (decl.$ === "ContractInit") { + initFns.push(decl); + } else { + locals.push(decl); + } + } + const [initFn, ...restInitFns] = initFns; + for (const fn of restInitFns) { + ctx.err.tooMuchInit()(ctx.toRange(fn.loc)); + } + + const init = (() => { + if (typeof parameters !== "undefined") { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (initFn) { + ctx.err.initFnAndParams()(ctx.toRange(initFn.loc)); + } + return Ast.InitParams(params, ctx.toRange(loc)); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + } else if (initFn) { + return Ast.InitFunction( + map(parseList(initFn.parameters), parseParameter)(ctx), + map(initFn.body, parseStatement)(ctx), + ctx.toRange(loc), + ); + } else { + return undefined; + } + })(); + + return Ast.Contract( + init, + parseTypeId(name)(ctx), + map(parseList(traits), parseTypeId)(ctx), + map(attributes, parseContractAttribute)(ctx), + parseLocalItems(locals)(ctx), + ctx.toRange(loc), + ); + }; + +const parseFunctionRaw = + (node: $ast.$Function): Handler => + (ctx) => { + const range = ctx.toRange(node.loc); + return Ast.Function( + !!parseNamedAttr("inline")(node.attributes)(ctx), + parseId(node.name)(ctx), + Ast.TFunction( + map(parseList(node.typeParams), parseTypeId)(ctx), + map(parseList(node.parameters), parseParameter)(ctx), + node.returnType + ? parseType(node.returnType)(ctx) + : Ast.TBasic(Ast.TVoid(range), range), + ), + node.body.$ === "FunctionDeclaration" + ? Ast.AbstractBody() + : Ast.RegularBody(map(node.body.body, parseStatement)(ctx)), + range, + ); + }; + +const parseExtension = + ( + parseFunction: (node: T) => Handler, + ) => + (node: T): Handler => + (ctx) => { + const fn = parseFunction(node)(ctx); + const get = parseGetAttribute(node.attributes)(ctx); + if (get) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (get.loc.kind !== "range") { + return throwInternal("Non-range in parser"); + } + ctx.err.globalGetter()(get.loc); + } + checkNoGlobalAttrs(node.attributes, ctx.toRange(node.loc))(ctx); + const isMutates = parseNamedAttr("mutates")(node.attributes)(ctx); + const isExtends = parseNamedAttr("extends")(node.attributes)(ctx); + if (!isExtends) { + if (isMutates) { + ctx.err.mutatesWithoutExtends()(isMutates); + } + return fn; + } + const [first, ...rest] = fn.type.params; + const selfType = (() => { + if ( + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + !first || + first.name.kind !== "id" || + first.name.text !== "self" + ) { + const range = ctx.toRange(node.loc); + ctx.err.extendsSelf()(range); + return Ast.TCons(Ast.TypeId("ERROR", range), [], range); + } + return first.type; + })(); + return Ast.Extension( + !!isMutates, + { ...fn, type: { ...fn.type, params: rest } }, + selfType, + ); + }; + +const parseMethod = + ( + parseFunction: (node: T) => Handler, + ) => + (node: T): Handler => + (ctx) => { + const fn = parseFunction(node)(ctx); + const get = parseGetAttribute(node.attributes)(ctx); + const inh = parseInheritance( + fn.body.kind !== "abstract_body", + node.attributes, + ctx.toRange(node.loc), + )(ctx); + const isMutates = parseNamedAttr("mutates")(node.attributes)(ctx); + const isExtends = parseNamedAttr("extends")(node.attributes)(ctx); + if (isExtends) { + ctx.err.localExtends()(ctx.toRange(node.loc)); + } + return Ast.Method(!!isMutates, inh.overridable, inh.override, get, fn); + }; + +const parseMessageDecl = + ({ + name, + opcode, + fields, + loc, + }: $ast.MessageDecl): Handler => + (ctx) => { + return Ast.MessageDecl( + parseTypeId(name)(ctx), + opcode ? parseExpression(opcode)(ctx) : undefined, + map(parseList(fields), parseFieldDecl)(ctx), + ctx.toRange(loc), + ); + }; + +const parseNativeFunctionDecl = + ({ + name, + attributes, + typeParams, + nativeName, + parameters, + returnType, + loc, + }: $ast.NativeFunctionDecl): Handler => + (ctx) => { + const range = ctx.toRange(loc); + return Ast.Function( + !!parseNamedAttr("inline")(attributes)(ctx), + parseId(name)(ctx), + Ast.TFunction( + map(parseList(typeParams), parseTypeId)(ctx), + map(parseList(parameters), parseParameter)(ctx), + returnType ? parseType(returnType)(ctx) : Ast.TBasic(Ast.TVoid(range), range), + ), + Ast.NativeBody(parseFuncId(nativeName)(ctx)), + range, + ); + }; + +const parseAlias = + ({ name, typeParams, type, loc }: $ast.AliasDecl): Handler => + (ctx) => { + return Ast.AliasDecl( + parseTypeId(name)(ctx), + map(parseList(typeParams), parseTypeId)(ctx), + parseType(type)(ctx), + ctx.toRange(loc), + ); + }; + +const parseUnion = + ({ + name, + typeParams, + cases, + loc, + }: $ast.UnionDecl): Handler => + (ctx) => { + return Ast.UnionDecl( + parseTypeId(name)(ctx), + map(parseList(typeParams), parseTypeId)(ctx), + map(cases, parseUnionCase)(ctx), + ctx.toRange(loc), + ); + }; + +const parseUnionCase = + ({ name, fields }: $ast.Case): Handler => + (ctx) => { + return Ast.UnionCase( + parseTypeId(name)(ctx), + map(parseList(fields), parseFieldDecl)(ctx), + ); + }; + +const parseStructDecl = + ({ + name, + typeParams, + fields, + loc, + }: $ast.StructDecl): Handler => + (ctx) => { + return Ast.StructDecl( + parseTypeId(name)(ctx), + map(parseList(typeParams), parseTypeId)(ctx), + map(parseList(fields), parseFieldDecl)(ctx), + ctx.toRange(loc), + ); + }; + +const parseContractAttribute = + ({ name, loc }: $ast.ContractAttribute): Handler => + (ctx) => { + return Ast.ContractAttribute( + parseStringLiteral(name)(ctx).value, + ctx.toRange(loc), + ); + }; + +const parseTrait = + ({ + name, + traits, + attributes, + declarations, + loc, + }: $ast.Trait): Handler => + (ctx) => { + return Ast.Trait( + parseTypeId(name)(ctx), + traits ? map(parseList(traits), parseTypeId)(ctx) : [], + map(attributes, parseContractAttribute)(ctx), + parseLocalItems(declarations)(ctx), + ctx.toRange(loc), + ); + }; + +type LocalItem = Ast.FieldDecl | Ast.Receiver | Ast.Method | Ast.FieldConstant; +const parseLocalItem: (input: $ast.traitItemDecl) => Handler = + makeVisitor<$ast.traitItemDecl>()({ + FieldDecl: parseFieldDecl, + Receiver: parseReceiver, + Function: parseMethod(parseFunctionRaw), + AsmFunction: parseMethod(parseAsmFunctionRaw), + Constant: parseFieldConstant, + }); + +const parseLocalItems = + (items: readonly $ast.traitItemDecl[]): Handler => + (ctx) => { + const locals = map(items, parseLocalItem)(ctx); + + const fields: Ast.FieldDecl[] = []; + const methods: Ast.Method[] = []; + const receivers: Ast.Receiver[] = []; + const constants: Ast.FieldConstant[] = []; + + for (const item of locals) { + switch (item.kind) { + case "field_decl": { + fields.push(item); + continue; + } + case "receiver": { + receivers.push(item); + continue; + } + case "method": { + methods.push(item); + continue; + } + case "field_const": { + constants.push(item); + continue; + } + } + } + return { fields, methods, receivers, constants }; + }; + +type ModuleItemAux = Exclude<$ast.moduleItem, $ast.PrimitiveTypeDecl>; + +const parseModuleItemAux: (input: ModuleItemAux) => Handler = + makeVisitor()({ + Function: parseExtension(parseFunctionRaw), + AsmFunction: parseExtension(parseAsmFunctionRaw), + NativeFunctionDecl: parseExtension(parseNativeFunctionDecl), + Constant: parseConstantGlobal, + StructDecl: parseStructDecl, + MessageDecl: parseMessageDecl, + Contract: parseContract, + Trait: parseTrait, + UnionDecl: parseUnion, + AliasDecl: parseAlias, + }); + +type ModuleItem = Ast.Function | Ast.Extension | Ast.Constant | Ast.TypeDecl; + +const parseModuleItem = + (node: $ast.moduleItem): Handler => + (ctx) => { + if (node.$ === "PrimitiveTypeDecl") { + ctx.err.deprecatedPrimitiveDecl()(ctx.toRange(node.loc)); + return []; + } + return [parseModuleItemAux(node)(ctx)]; + }; + +const parseImport = + ({ path, loc }: $ast.Import): Handler => + (ctx) => { + const stringLiteral = parseStringLiteral(path)(ctx); + const parsedString: string = JSON.parse(`"${stringLiteral.value}"`); + return Ast.Import( + parseImportString(parsedString, ctx.toRange(loc), ctx.err.imports), + ctx.toRange(loc), + ); + }; + +const splitItems = (items: readonly ModuleItem[]): Ast.ModuleItems => { + const functions: Ast.Function[] = []; + const constants: Ast.Constant[] = []; + const extensions: Ast.Extension[] = []; + const types: Ast.TypeDecl[] = []; + for (const item of items) { + switch (item.kind) { + case "function": + functions.push(item); + continue; + case "extension": + extensions.push(item); + continue; + case "constant": + constants.push(item); + continue; + case "struct_decl": + case "message_decl": + case "union_decl": + case "alias_decl": + case "contract": + case "trait": + types.push(item); + continue; + } + } + return { functions, constants, extensions, types }; +}; + +const parseModule = + ({ imports, items }: $ast.Module): Handler => + (ctx) => { + return Ast.Module( + map(imports, parseImport)(ctx), + splitItems(map(items, parseModuleItem)(ctx).flat()), + ); + }; + +export const parse = ( + log: SourceLogger, + code: string, + path: string, +): Ast.Module => { + const err = SyntaxErrors(log); + + const result = $.parse({ + grammar: G.Module, + space: G.space, + text: code, + }); + + if (result.$ === "error") { + const { expected, position } = result.error; + err.expected(expected)({ + start: position, + end: position, + }); + return Ast.Module([], { + constants: [], + extensions: [], + functions: [], + types: [], + }); + } + + const toRange = (loc: $.Loc): Ast.Range => { + if (loc.$ === "empty") { + return throwInternal("Lookahead at top level"); + } + const { start, end } = loc; + return Ast.Range(start, end, path, code); + }; + + return parseModule(result.value)({ + err, + toRange, + }); +}; diff --git a/src/next/imports/reader.ts b/src/next/imports/reader.ts new file mode 100644 index 0000000000..f379af588a --- /dev/null +++ b/src/next/imports/reader.ts @@ -0,0 +1,178 @@ +import { parse } from "@/next/grammar"; +import { emptyPath, fromString } from "@/imports/path"; +import { parentPath, createMemoryFs, createProxyFs } from "@/next/fs"; +import { getFiles } from "@/next/stdlib"; +import type { Cursor } from "@/next/fs"; +import type { AnyLogger, Logger, SourceLogger } from "@/error/logger-util"; +import type { + FuncImport, + Implicit, + ResolvedImport, + TactImport, + TactSource, +} from "@/next/imports/source"; +import type { ModuleItems, Loc } from "@/next/ast"; +import { hideProperty } from "@/utils/tricks"; + +type Options = { + readonly log: Logger; + /** + * Cursor to root of file system with project files + */ + readonly project: Cursor; + /** + * Cursor to root of stdlib file system + */ + readonly stdlib: Cursor; + /** + * Implicit imports (without `import "..."`) to add + * into every source + */ + readonly implicits: readonly ResolvedImport[]; + /** + * Name of root source file of the project + */ + readonly root: string; +}; + +export const readSource = async ({ + log, + project, + stdlib, + implicits, + root, +}: Options): Promise => { + const status: Map = new Map(); + + const resolveImports = async ( + path: string, + log: SourceLogger, + file: Cursor, + code: string, + ): Promise => { + const { imports: rawImports, items } = parse(log, code, path); + const imports: ResolvedImport[] = [...implicits]; + for (const { importPath, loc } of rawImports) { + const { language, path, type } = importPath; + const importedFile = + type === "relative" + ? file.focus(parentPath).focus(path) + : stdlib.focus(path); + if (language === "tact") { + const source = await resolveSource(importedFile, log); + if (source) { + imports.push(TactImport(source, loc)); + } + } else { + imports.push(FuncImport(code, loc)); + } + } + return { kind: "tact", path, code, imports, items }; + }; + + const resolveSource = async ( + file: Cursor, + parentLog: AnyLogger, + ): Promise => { + const path = file.getAbsolutePathForLog(); + const res = status.get(path); + if (typeof res === "object") { + return res; + } + if (res === "pending") { + parentLog.error( + parentLog.text`Cyclic import: ${parentLog.path(path)}`, + ); + return; + } + status.set(path, "pending"); + const code = await file.read(); + if (!code) { + return; + } + const source = await log.source(path, code, (log) => { + return resolveImports(path, log, file, code); + }); + status.set(path, source); + return source; + }; + + return resolveSource(project.focus(fromString(root)), log); +}; + +/** + * Read standard library and prepare for reading projects + */ +export const ProjectReader = async (log: Logger) => { + const stdRoot = createMemoryFs({ + log, + files: getFiles(), + root: emptyPath, + isReadonly: true, + }); + const stdLibs = stdRoot.focus(fromString("libs")); + const stdStd = await readSource({ + log, + project: stdRoot, + stdlib: stdLibs, + implicits: [], + root: "std/stdlib.tact", + }); + if (!stdStd) { + // Could not load standard library + // No compilation is possible + return; + } + + /** + * Read project + */ + const read = async (fsRootPath: string, tactRoot: string) => { + const project = createProxyFs({ + log, + root: fsRootPath, + isReadonly: false, + }); + const implicits: ResolvedImport[] = [ + { + kind: "tact", + source: stdStd, + loc: { + kind: "implicit", + }, + }, + ]; + return await readSource({ + log, + project, + stdlib: stdLibs, + implicits, + root: tactRoot, + }); + }; + + return { read }; +}; + +const TactImport = (source: TactSource, loc: Loc | Implicit) => { + const result: TactImport = { kind: "tact", source, loc }; + hideProperty(result, "source"); + return result; +}; + +const FuncImport = (code: string, loc: Loc) => { + const result: FuncImport = { kind: "func", code, loc }; + hideProperty(result, "code"); + return result; +}; + +const TactSource = ( + path: string, + code: string, + imports: readonly ResolvedImport[], + items: ModuleItems, +) => { + const result: TactSource = { kind: "tact", path, code, imports, items }; + hideProperty(result, "code"); + return result; +}; diff --git a/src/next/imports/source.ts b/src/next/imports/source.ts new file mode 100644 index 0000000000..6232c21fc1 --- /dev/null +++ b/src/next/imports/source.ts @@ -0,0 +1,25 @@ +import type { ModuleItems, Loc } from "@/next/ast"; + +export type TactSource = { + readonly kind: "tact"; + readonly path: string; + readonly code: string; + readonly imports: readonly ResolvedImport[]; + readonly items: ModuleItems; +}; + +export type ResolvedImport = TactImport | FuncImport; +export type TactImport = { + readonly kind: "tact"; + readonly source: TactSource; + readonly loc: Loc | Implicit; +}; +export type FuncImport = { + readonly kind: "func"; + readonly code: string; + readonly loc: Loc; +}; + +export type Implicit = { + readonly kind: "implicit"; +}; diff --git a/src/next/index.ts b/src/next/index.ts new file mode 100644 index 0000000000..4142ce691d --- /dev/null +++ b/src/next/index.ts @@ -0,0 +1,35 @@ +import path from "path"; +import { TerminalLogger } from "@/cli/logger"; +import { getAnsiMarkup, isColorSupported } from "@/cli/colors"; +import { ProjectReader } from "@/next/imports/reader"; +import { inspect } from "util"; +import { scope } from "@/next/scoping/typecheck"; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const dump = (obj: unknown) => + // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression + console.log(inspect(obj, { colors: false, depth: Infinity })); + +const main = async () => { + const ansi = getAnsiMarkup(isColorSupported()); + await TerminalLogger(path, "info", ansi, async (log) => { + await log.recover(async (log) => { + // TODO: new CLI based (see typegen) + const reader = await ProjectReader(log); + if (!reader) return; + const result = await reader.read( + path.join(__dirname, "example"), + // TODO: parseImportString(root, ImportErrors(log)) when there are CLI/config loggers + "scope1-a.tact", + ); + if (!result) { + return; + } + // dump(result.sources.length); + // dump(result); + dump(scope(log, result).functions.keys()); + }); + }); +}; + +void main(); diff --git a/src/next/stdlib/index.ts b/src/next/stdlib/index.ts new file mode 100644 index 0000000000..c755e32bdc --- /dev/null +++ b/src/next/stdlib/index.ts @@ -0,0 +1,21 @@ +import { files as filesBase64 } from "@/stdlib/stdlib"; + +function base64ToBlob(base64: string): Blob { + const binary = atob(base64); + const len = binary.length; + const bytes = new Uint8Array(len); + for (let i = 0; i < len; ++i) { + bytes[i] = binary.charCodeAt(i); + } + return new Blob([bytes], { type: "text/plain;charset=utf-8" }); +} + +export const getFiles = () => { + const files: Map = new Map(); + + for (const [path, base64] of Object.entries(filesBase64)) { + files.set(path, base64ToBlob(base64)); + } + + return files; +}; diff --git a/src/next/test/_cli.build.ts b/src/next/test/_cli.build.ts new file mode 100644 index 0000000000..b7aa496b73 --- /dev/null +++ b/src/next/test/_cli.build.ts @@ -0,0 +1,9 @@ +import { resolve } from "path"; +import { runTest } from "@/next/test/_test.build"; + +const main = async () => { + const path = resolve(process.argv[2] ?? ""); + console.log(await runTest(path)); +}; + +void main(); diff --git a/src/next/test/_run.test.ts b/src/next/test/_run.test.ts new file mode 100644 index 0000000000..0dc76b9dd2 --- /dev/null +++ b/src/next/test/_run.test.ts @@ -0,0 +1,39 @@ +import fs from "fs"; +import { readFile, writeFile } from "fs/promises"; +import { basename, dirname, extname, join } from "path"; +import { runTest } from "@/next/test/_test.build"; + +const root = __dirname; + +const listCases = (): readonly string[] => { + return fs + .readdirSync(root) + .filter((file) => file.endsWith(".tact")) + .map((file) => join(root, file)); +}; + +const readFileOpt = async (path: string): Promise => { + try { + return await readFile(path, "utf8"); + } catch (err) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (err && (err as any).code === "ENOENT") return undefined; + throw err; + } +}; + +it.each(listCases())("%s", async (path) => { + const newText = await runTest(path); + const snapPath = join( + dirname(path), + basename(path, extname(path)) + ".snap.js", + ); + const isUpdate = expect.getState().snapshotState._updateSnapshot === "all"; + const oldText = await readFileOpt(snapPath); + if (isUpdate || typeof oldText === "undefined") { + await writeFile(snapPath, newText, "utf-8"); + expect(newText).toBe(newText); + } else { + expect(newText).toBe(oldText); + } +}); diff --git a/src/next/test/_test.build.ts b/src/next/test/_test.build.ts new file mode 100644 index 0000000000..cd01243714 --- /dev/null +++ b/src/next/test/_test.build.ts @@ -0,0 +1,61 @@ +import { createMemoryFs, createProxyFs, fromString } from "@/next/fs"; +import { ProjectReader, readSource } from "@/next/imports/reader"; +import { toJs } from "@/next/test/to-code"; +import { typecheck } from "@/next/types/typecheck"; +import { runServer } from "@/server/run-server"; +import { basename, dirname } from "path"; +import type { Logger } from "@/error/logger-util"; +import type { ResolvedImport, TactSource } from "@/next/imports/source"; +import { lowerSource } from "@/next/types/lower"; +import { runLog } from "@/next/ast"; + +export const runTest = async (path: string): Promise => { + let source: TactSource | undefined; + const entries = await runServer(async (log) => { + await log.recover(async (log) => { + // const result = await buildNoStdlib(log, path); + const result = await buildE2E(log, path); + + if (!result) { + return; + } + + source = result; + }); + }); + if (entries.length > 0 || !source) { + return toJs(entries); + } + const [csource, errors1] = typecheck(source); + const [lowered, errors2] = runLog(lowerSource(csource)); + return toJs({ lowered, errors: [...errors1, ...errors2] }); +}; + +export const buildE2E = async (log: Logger, path: string) => { + const reader = await ProjectReader(log); + if (!reader) { + return; + } + return await reader.read(dirname(path), basename(path)); +}; + +export const buildNoStdlib = async (log: Logger, path: string) => { + const project = createProxyFs({ + log, + root: dirname(path), + isReadonly: false, + }); + const implicits: ResolvedImport[] = []; + return await readSource({ + log, + project, + stdlib: createMemoryFs({ + log, + files: new Map(), + isReadonly: true, + root: fromString("."), + }), + implicits, + root: basename(path), + }); +}; diff --git a/src/next/test/fun-shadow-1.snap.js b/src/next/test/fun-shadow-1.snap.js new file mode 100644 index 0000000000..4a14bd2eb1 --- /dev/null +++ b/src/next/test/fun-shadow-1.snap.js @@ -0,0 +1,46 @@ +const x1 = { + kind: "range", + start: 32, + end: 44, +}; + +export default { + types: { + scope: { + functions: new Map([ + [ + "foo", + { + value: { + kind: "function", + inline: false, + name: { + kind: "id", + text: "foo", + loc: { + kind: "range", + start: 36, + end: 39, + }, + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: "regular_body", + statements: [], + }, + loc: x1, + }, + via: { + kind: "user", + imports: [], + defLoc: x1, + }, + }, + ], + ]), + }, + }, + result: [], +}; diff --git a/src/next/test/fun-shadow-1.tact b/src/next/test/fun-shadow-1.tact new file mode 100644 index 0000000000..e1c3ac1f1f --- /dev/null +++ b/src/next/test/fun-shadow-1.tact @@ -0,0 +1,3 @@ +// regular function definition + +fun foo() {} diff --git a/src/next/test/fun-shadow-2.snap.js b/src/next/test/fun-shadow-2.snap.js new file mode 100644 index 0000000000..568edc5647 --- /dev/null +++ b/src/next/test/fun-shadow-2.snap.js @@ -0,0 +1,41 @@ +export default { + types: { + errors: [ + { + loc: { + kind: "range", + start: 82, + end: 94, + }, + descr: [ + { + kind: "text", + text: 'There already is a function "foo" from', + }, + { + kind: "via", + via: { + kind: "user", + imports: [ + { + kind: "tact", + loc: { + kind: "range", + start: 56, + end: 80, + }, + }, + ], + defLoc: { + kind: "range", + start: 32, + end: 44, + }, + }, + }, + ], + }, + ], + }, + result: [], +}; diff --git a/src/next/test/fun-shadow-2.tact b/src/next/test/fun-shadow-2.tact new file mode 100644 index 0000000000..cfd7a03be7 --- /dev/null +++ b/src/next/test/fun-shadow-2.tact @@ -0,0 +1,5 @@ +// Fails, because fun-shadow-1 already has foo defined + +import "./fun-shadow-1"; + +fun foo() {} diff --git a/src/next/test/fun-shadow-3.snap.js b/src/next/test/fun-shadow-3.snap.js new file mode 100644 index 0000000000..57e2d875aa --- /dev/null +++ b/src/next/test/fun-shadow-3.snap.js @@ -0,0 +1,55 @@ +const x1 = { + kind: "range", + start: 32, + end: 44, +}; + +export default { + types: { + scope: { + functions: new Map([ + [ + "foo", + { + value: { + kind: "function", + inline: false, + name: { + kind: "id", + text: "foo", + loc: { + kind: "range", + start: 36, + end: 39, + }, + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: "regular_body", + statements: [], + }, + loc: x1, + }, + via: { + kind: "user", + imports: [ + { + kind: "tact", + loc: { + kind: "range", + start: 47, + end: 71, + }, + }, + ], + defLoc: x1, + }, + }, + ], + ]), + }, + }, + result: [], +}; diff --git a/src/next/test/fun-shadow-3.tact b/src/next/test/fun-shadow-3.tact new file mode 100644 index 0000000000..bf14ace51b --- /dev/null +++ b/src/next/test/fun-shadow-3.tact @@ -0,0 +1,3 @@ +// reexporting the function from fun-shadow-1 + +import "./fun-shadow-1"; diff --git a/src/next/test/fun-shadow-4.snap.js b/src/next/test/fun-shadow-4.snap.js new file mode 100644 index 0000000000..e32bb706b2 --- /dev/null +++ b/src/next/test/fun-shadow-4.snap.js @@ -0,0 +1,55 @@ +const x1 = { + kind: "range", + start: 32, + end: 44, +}; + +export default { + types: { + scope: { + functions: new Map([ + [ + "foo", + { + value: { + kind: "function", + inline: false, + name: { + kind: "id", + text: "foo", + loc: { + kind: "range", + start: 36, + end: 39, + }, + }, + typeParams: [], + returnType: undefined, + params: [], + body: { + kind: "regular_body", + statements: [], + }, + loc: x1, + }, + via: { + kind: "user", + imports: [ + { + kind: "tact", + loc: { + kind: "range", + start: 90, + end: 114, + }, + }, + ], + defLoc: x1, + }, + }, + ], + ]), + }, + }, + result: [], +}; diff --git a/src/next/test/fun-shadow-4.tact b/src/next/test/fun-shadow-4.tact new file mode 100644 index 0000000000..4dda7369f6 --- /dev/null +++ b/src/next/test/fun-shadow-4.tact @@ -0,0 +1,5 @@ +// fun-shadow-3 reexports the same functions +// as fun-shadow-1, and it should not clash + +import "./fun-shadow-1"; +import "./fun-shadow-3"; diff --git a/src/next/test/fun-shadow-5.snap.js b/src/next/test/fun-shadow-5.snap.js new file mode 100644 index 0000000000..82f0ac7a86 --- /dev/null +++ b/src/next/test/fun-shadow-5.snap.js @@ -0,0 +1,41 @@ +export default { + types: { + errors: [ + { + loc: { + kind: "range", + start: 136, + end: 148, + }, + descr: [ + { + kind: "text", + text: 'There already is a function "foo" from', + }, + { + kind: "via", + via: { + kind: "user", + imports: [ + { + kind: "tact", + loc: { + kind: "range", + start: 85, + end: 109, + }, + }, + ], + defLoc: { + kind: "range", + start: 32, + end: 44, + }, + }, + }, + ], + }, + ], + }, + result: [], +}; diff --git a/src/next/test/fun-shadow-5.tact b/src/next/test/fun-shadow-5.tact new file mode 100644 index 0000000000..46390d0c0b --- /dev/null +++ b/src/next/test/fun-shadow-5.tact @@ -0,0 +1,7 @@ +// fails: we're redefining a function from fun-shadow-1 +// must have only one error + +import "./fun-shadow-1"; +import "./fun-shadow-3"; + +fun foo() {} diff --git a/src/next/test/to-code.ts b/src/next/test/to-code.ts new file mode 100644 index 0000000000..20ceb01d8d --- /dev/null +++ b/src/next/test/to-code.ts @@ -0,0 +1,171 @@ +import { isThunk, printSym } from "@/next/ast"; + +function isValidId(key: string) { + return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key); +} + +const pad = (s: readonly string[]) => s.map((s) => " " + s); + +function concat(s: readonly string[], t: readonly string[]): readonly string[] { + const [last, ...init] = [...s].reverse(); + const [head, ...tail] = t; + if (typeof last === "undefined") { + return t; + } else if (typeof head === "undefined") { + return s; + } else { + return [...init.reverse(), last + head, ...tail]; + } +} + +function concatAll(s: readonly (readonly string[])[]): readonly string[] { + return s.reduce((acc, next) => concat(acc, next), []); +} + +const braced = (l: string, code: readonly string[], r: string) => { + const m = pad(code); + return m.length === 0 ? [l + r] : [l, ...m, r]; +}; + +export function toJs(value: unknown): string { + const counts: Map = new Map(); + const order: Map = new Map(); + let nextId = 0; + function countUsages(val: unknown) { + if ( + typeof val !== "object" || + val === null || + val instanceof Date || + val instanceof RegExp + ) { + return; + } + const newCount = counts.get(val); + if (!newCount) { + counts.set(val, "exists"); + const items = Array.isArray(val) + ? val + : val instanceof Map + ? val.entries().flatMap((kv) => kv) + : val instanceof Set + ? [...val] + : Object.entries(val); + + for (const item of items) { + countUsages(item); + } + } else if (newCount === "exists") { + const name = `x${++nextId}`; + counts.set(val, { name }); + } + } + + function show(val: unknown): readonly string[] { + const count = counts.get(val); + if (typeof count !== "object") { + return showAny(val); + } + if (!order.has(count.name)) { + // set as being prepared + order.set(count.name, []); + const res = showAny(val); + order.set(count.name, res); + } + return [count.name]; + } + + function showAny(val: unknown): readonly string[] { + switch (typeof val) { + case "string": + return [JSON.stringify(val)]; + case "number": + return [String(val)]; + case "boolean": + return [String(val)]; + case "bigint": + return [val.toString() + "n"]; + case "symbol": + return [ + val.description + ? `Symbol(${JSON.stringify(val.description)})` + : "Symbol()", + ]; + case "undefined": + return ["undefined"]; + case "object": + return val === null ? ["null"] : showObject(val); + case "function": + return showFunction(val); + } + } + + // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type + const showFunction = (val: Function): readonly string[] => { + if (!isThunk(val)) { + return [`new Function(${val.toString()})`]; + } + const result = val[printSym](); + if (result === "waiting") { + return [`Waiting()`]; + } else if (result === "running") { + return [`Running()`]; + } else { + return show(result); + } + }; + + const showObject = (val: object): readonly string[] => { + if (val instanceof Date) { + return [`new Date(${val.getTime()})`]; + } + if (val instanceof RegExp) { + return [val.toString()]; // sus + } + if (Array.isArray(val)) { + return braced( + "[", + val.flatMap((item) => { + return concat(show(item), [","]); + }), + "]", + ); + } + if (val instanceof Map) { + return braced( + "new Map([", + [...val.entries()].flatMap(([k, v]) => { + return concatAll([["["], show(k), [", "], show(v), ["],"]]); + }), + "])", + ); + } + if (val instanceof Set) { + return braced( + "new Set([", + [...val].flatMap((k) => { + return concat(show(k), [","]); + }), + "])", + ); + } + return braced( + "{", + Object.entries(val).flatMap(([k, v]) => { + const keyRep = isValidId(k) ? k : JSON.stringify(k); + return concatAll([[keyRep], [": "], show(v), [","]]); + }), + "}", + ); + }; + + countUsages(value); + const res = show(value); + + const code = [...order.entries()] + .flatMap(([varName, code]) => { + return concatAll([[`const ${varName} = `], code, [";"]]); + }) + .join("\n"); + + return `${code ? `${code}\n\n` : ""}export default ${res.join("\n")};\n`; +} diff --git a/src/next/types/alias.ts b/src/next/types/alias.ts new file mode 100644 index 0000000000..71e10464ad --- /dev/null +++ b/src/next/types/alias.ts @@ -0,0 +1,17 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { decodeTypeParams } from "@/next/types/type-params"; +import { decodeTypeLazy } from "@/next/types/type"; + +export function* decodeAlias( + Lazy: Ast.ThunkBuilder, + { typeParams, type }: Ast.AliasDecl, + scopeRef: () => Ast.CSource, +): Ast.Log { + const decodedParams = yield* decodeTypeParams(typeParams); + return Ast.CAlias( + decodedParams, + decodeTypeLazy(Lazy, decodedParams, type, scopeRef), + ); +} diff --git a/src/next/types/body.ts b/src/next/types/body.ts new file mode 100644 index 0000000000..3b6441408f --- /dev/null +++ b/src/next/types/body.ts @@ -0,0 +1,262 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { isSubsetOf } from "@/utils/isSubsetOf"; +import { decodeStatementsLazy } from "@/next/types/statements"; + +export function* decodeBody( + Lazy: Ast.ThunkBuilder, + node: Ast.FunctionalBody, + fnType: Ast.CTFunction | Ast.CTMethod, + loc: Ast.Loc, + scopeRef: () => Ast.CSource, +): Ast.Log { + switch (node.kind) { + case "abstract_body": { + yield ENoBody(loc); + return Ast.CTactBody( + Lazy({ + callback: function* () { + return undefined; + }, + context: [Ast.TEText("checking body of function")], + loc, + recover: undefined, + }), + ); + } + case "regular_body": { + return Ast.CTactBody( + decodeStatementsLazy( + Lazy, + loc, + node.statements, + () => fnType, + true, + scopeRef, + ), + ); + } + case "asm_body": { + return Ast.CFiftBody( + Lazy({ + callback: () => + checkShuffle(node.shuffle, fnType, loc, scopeRef), + context: [Ast.TEText("checking shuffle")], + loc, + recover: undefined, + }), + node.instructions, + ); + } + case "native_body": { + return Ast.CFuncBody(node.nativeName); + } + } +} + +const ENoBody = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Function must have a body`), +); + +function* checkShuffle( + shuffle: Ast.AsmShuffle, + fnType: Ast.CTFunction | Ast.CTMethod, + loc: Ast.Loc, + scopeRef: () => Ast.CSource, +) { + const { args, ret } = shuffle; + if (args.length !== 0) { + const argSet = new Set(args.map((id) => id.text)); + + if (argSet.size !== args.length) { + yield EDuplicateArgs(loc); + } + + const paramsArray: string[] = []; + for (const typedId of fnType.params.order) { + if (typedId.name.kind === "wildcard") { + yield EWildcardArgs(loc); + } else { + paramsArray.push(typedId.name.text); + } + } + + if (fnType.kind === 'DecodedMethodType') { + paramsArray.push("self"); + } + + const paramSet = new Set(paramsArray); + if (!isSubsetOf(paramSet, argSet)) { + yield EMissingArgs(loc); + } + + if (!isSubsetOf(argSet, paramSet)) { + yield EExtraArgs(loc); + } + } + + if (ret.length !== 0) { + const shuffleRetSet = new Set(ret.map((num) => num.value)); + if (shuffleRetSet.size !== ret.length) { + yield EDuplicateRet(loc); + } + + const retTupleSize = yield* getRetTupleSize(fnType, scopeRef); + + if (typeof retTupleSize !== "undefined") { + const returnValueSet = new Set([ + ...Array(retTupleSize) + .keys() + .map((x) => BigInt(x)), + ]); + + if (!isSubsetOf(returnValueSet, shuffleRetSet)) { + yield EMissingRet(loc); + } + + if (!isSubsetOf(shuffleRetSet, returnValueSet)) { + yield EExtraRet(loc); + } + } + } + + return shuffle; +} + +function* getRetTupleSize( + { kind, returnType }: Ast.CTFunction | Ast.CTMethod, + scopeRef: () => Ast.CSource, +): Ast.Log { + const type = yield* returnType(); + const baseSize = yield* getTypeTupleSize(type, scopeRef); + if (typeof baseSize === "undefined") { + return undefined; + } + return baseSize + (kind === "DecodedMethodType" ? 1 : 0); +} + +function* getTypeTupleSize(type: Ast.CType, scopeRef: () => Ast.CSource): Ast.Log { + switch (type.kind) { + case "recover": { + return undefined; + } + case "type_ref": { + const decl = scopeRef().typeDecls.get(type.name.text); + if (!decl) { + return undefined; + } + switch (decl.decl.kind) { + case "contract": { + const content = yield* decl.decl.content(); + return content.fieldish.order.length; + } + case "struct": + case "message": { + return decl.decl.fields.order.length; + } + case "union": { + // unions don't have exact size + return undefined; + } + case "alias": { + // aliases already handled by decoder + return undefined; + } + case "trait": { + // traits cannot be used as types + return undefined; + } + } + // typescript wants this + return undefined; + } + case "TypeAlias": { + return undefined; + } + case "TypeParam": { + // this size can be anything + return undefined; + } + case "map_type": { + return 1; + } + case "TypeBounced": { + // undefined can have weird encodings + return undefined; + } + case "TypeMaybe": { + return yield* getTypeTupleSize(type.type, scopeRef); + } + case "tuple_type": { + return 1; + } + case "tensor_type": { + return type.typeArgs.length; + } + case "basic": { + switch (type.type.kind) { + case "TypeStateInit": { + return 2; + } + case "TyInt": + case "TySlice": + case "TyCell": + case "TyBuilder": + case "unit_type": + case "TypeBool": + case "TypeAddress": + case "TypeString": + case "TypeStringBuilder": + case "TypeNull": { + return 1; + } + case "TypeVoid": { + return 0; + } + } + } + } +} + +const EDuplicateArgs = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Argument rearrangement cannot have duplicates`), +); + +const EWildcardArgs = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Argument rearrangement cannot use wildcards`) +); + +const EMissingArgs = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText( + `Argument rearrangement must mention all function parameters`, + ), +); + +const EExtraArgs = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText( + `Argument rearrangement must mention only function parameters`, + ), +); + +const EDuplicateRet = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Return rearrangement cannot have duplicates`) +); + +const EMissingRet = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Return rearrangement must mention all function parameters`), +); + +const EExtraRet = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText( + `Return rearrangement must mention only function parameters`, + ), +); diff --git a/src/next/types/builtins.ts b/src/next/types/builtins.ts new file mode 100644 index 0000000000..e024835a1d --- /dev/null +++ b/src/next/types/builtins.ts @@ -0,0 +1,255 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ + +import * as Ast from "@/next/ast"; + +// FIXME +export const tactMethodIds = [113617n, 115390n, 121275n]; + +const r = Ast.Builtin(); + +const TypeParams = (typeParams: readonly string[]): Ast.CTypeParams => { + const arr = typeParams.map((name) => Ast.TypeId(name, r)); + return Ast.CTypeParams(arr, new Set(typeParams)); +}; + +const Params = (params: Record): Ast.CParameters => { + const order: Ast.CParameter[] = []; + const set: Set = new Set(); + for (const [name, type] of Object.entries(params)) { + order.push(Ast.CParameter(Ast.Id(name, r), Ast.FakeThunk(type), r)); + set.add(name); + } + return Ast.CParameters(order, set); +}; + +const Ref = (name: string): Ast.CTParamRef => { + return Ast.CTParamRef(Ast.TypeId(name, r), r); +}; + +const mapType = Ast.SVTMap(Ref("K"), Ref("V"), r); + +const GenericFn = ( + name: string, + typeParams: readonly string[], + params: Record, + returnType: Ast.CType, +): [string, Ast.CTFunction] => { + return [ + name, + Ast.CTFunction( + TypeParams(typeParams), + Params(params), + Ast.FakeThunk(returnType), + ), + ]; +}; +const Fn = ( + name: string, + params: Record, + returnType: Ast.CType, +): [string, Ast.CTFunction] => { + return GenericFn(name, [], params, returnType); +}; +const MapMethod = ( + name: string, + mutates: boolean, + params: Record, + returnType: Ast.CType, +): [string, Ast.CTMethod] => { + return [ + name, + Ast.CTMethod( + mutates, + TypeParams(["K", "V"]), + mapType, + Params(params), + Ast.FakeThunk(returnType), + ), + ]; +}; + +export const Int = Ast.CTBasic(Ast.TInt(Ast.IFInt("signed", 257, r), r), r); +export const Slice = Ast.CTBasic(Ast.TSlice(Ast.SFDefault(r), r), r); +export const Cell = Ast.CTBasic(Ast.TCell(Ast.SFDefault(r), r), r); +export const Builder = Ast.CTBasic(Ast.TBuilder(Ast.SFDefault(r), r), r); +export const Void = Ast.CTBasic(Ast.TVoid(r), r); +export const Null = Ast.CTBasic(Ast.TNull(r), r); +export const Bool = Ast.CTBasic(Ast.TBool(r), r); +export const Address = Ast.CTBasic(Ast.TAddress(r), r); +export const String = Ast.CTBasic(Ast.TString(r), r); +export const StringBuilder = Ast.CTBasic(Ast.TStringBuilder(r), r); +export const MapType = (k: Ast.CType, v: Ast.CType) => + Ast.CTMap(k, v, r); +export const Maybe = (t: Ast.CType) => Ast.CTMaybe(t, r); +export const Unit = Ast.TUnit(r); +export const StateInit = Ast.CTBasic(Ast.TStateInit(r), r); + +export const stateInitFields = new Map([ + ["code", Cell], + ["data", Cell], +]); + +export const builtinTypes = new Map( + [ + "Int", + "Slice", + "Cell", + "Builder", + "Void", + "Null", + "Bool", + "Address", + "String", + "StringBuilder", + "Map", + "Maybe", + "StateInit", + ].map((s) => [s, s]), +); + +const ArithBin = (name: string) => { + return Fn(name, { left: Int, right: Int }, Int); +}; +const BoolBin = (name: string) => { + return Fn(name, { left: Bool, right: Bool }, Bool); +}; +const CompBin = (name: string) => { + return Fn(name, { left: Int, right: Int }, Bool); +}; +const EqBin = (name: string) => { + return GenericFn(name, ["T"], { left: Ref("T"), right: Ref("T") }, Bool); +}; +const ArithAssign = (name: string) => { + return Fn(name, { left: Int, right: Int }, Void); +}; +const BoolAssign = (name: string) => { + return Fn(name, { left: Bool, right: Bool }, Void); +}; + +export const builtinFunctions: Map = new Map([ + // dump(arg: T): Void + GenericFn("dump", ["T"], { data: Ref("T") }, Void), + // ton(value: String): Int + Fn("ton", { value: String }, Int), + // require(that: Bool, msg: String): Void + Fn("require", { that: Bool, msg: String }, Void), + // address(s: String): Address + Fn("address", { s: String }, Address), + // cell(bocBase64: String): Cell + Fn("cell", { bocBase64: String }, Cell), + // dumpStack(): Void + Fn("dumpStack", {}, Void), + // emptyMap(): map + GenericFn("emptyMap", ["K", "V"], {}, mapType), + // slice(bocBase64: String): Slice + Fn("slice", { bocBase64: String }, Slice), + // rawSlice(hex: String): Slice + Fn("rawSlice", { hex: String }, Slice), + // ascii(str: String): Int + Fn("ascii", { str: String }, Int), + // crc32(str: String): Int + Fn("crc32", { str: String }, Int), + // don't forget about our best friend, sha256 + // it is the only overloaded function in the language + // sha256(data: Slice | String): Int +]); + +export const builtinMethods: Map = new Map([ + // set(key: K, value: V): void + MapMethod("set", true, { key: Ref("K"), value: Ref("V") }, Void), + // get(key: K): Maybe + MapMethod("get", false, { key: Ref("K") }, Maybe(Ref("V"))), + // del(key: K): Bool + MapMethod("del", true, { key: Ref("K") }, Bool), + // asCell(): Maybe + MapMethod("asCell", false, {}, Maybe(Cell)), + // isEmpty(): Bool + MapMethod("isEmpty", false, {}, Bool), + // exists(key: K): Bool + MapMethod("exists", false, { key: Ref("K") }, Bool), + // deepEquals(other: map): Bool + MapMethod("deepEquals", false, { other: mapType }, Bool), + // replace(key: K, value: V): Bool + MapMethod("replace", true, { key: Ref("K"), value: Ref("V") }, Bool), + // replaceGet(key: K, value: V): map + MapMethod("replaceGet", true, { key: Ref("K"), value: Ref("V") }, mapType), +]); + +export const builtinUnary: Map = new Map([ + Fn("+", { arg: Int }, Int), + Fn("-", { arg: Int }, Int), + Fn("~", { arg: Int }, Int), + Fn("!", { arg: Bool }, Bool), + GenericFn("!!", ["T"], { arg: Maybe(Ref("T")) }, Ref("T")), +]); + +export const builtinBinary: Map = new Map([ + // (left: Int, right: Int): Int + ArithBin("+"), + ArithBin("-"), + ArithBin("*"), + ArithBin("/"), + ArithBin("%"), + ArithBin("<<"), + ArithBin(">>"), + ArithBin("&"), + ArithBin("|"), + ArithBin("^"), + // (left: Int, right: Int): Bool + CompBin(">"), + CompBin("<"), + CompBin(">="), + CompBin("<="), + // (left: T, right: T): Bool + EqBin("=="), + EqBin("!="), + // (left: Bool, right: Bool): Bool + BoolBin("&&"), + BoolBin("||"), +]); + +export const builtinAugmented: Map = new Map([ + // (left: Int, right: Int): Void; + ArithAssign("+="), + ArithAssign("-="), + ArithAssign("*="), + ArithAssign("/="), + ArithAssign("%="), + ArithAssign("<<="), + ArithAssign(">>="), + ArithAssign("&="), + ArithAssign("|="), + ArithAssign("^="), + // (left: Bool, right: Bool): Void; + BoolAssign("&&="), + BoolAssign("||="), +]); + +export const getStaticBuiltin = ( + type: Ast.CType, +): Map => { + return new Map([ + // Foo.fromSlice(slice: Slice) + Fn("fromSlice", { slice: Slice }, type), + // Foo.fromSlice(cell: Cell) + Fn("fromCell", { cell: Cell }, type), + ]); +}; + +// TODO: convert into methods, use `mutates` from them in `lookupMethod` +export const structBuiltin = new Map([ + // Foo.toSlice(): Slice + Fn("toSlice", {}, Slice), + // Foo.toCell(): Cell + Fn("toCell", {}, Cell), +]); + +export const messageBuiltin = new Map([ + // Foo.toSlice(): Slice + Fn("toSlice", {}, Slice), + // Foo.toCell(): Cell + Fn("toCell", {}, Cell), + // Foo.opcode(): Int + Fn("opcode", {}, Int), +]); diff --git a/src/next/types/constant-def.ts b/src/next/types/constant-def.ts new file mode 100644 index 0000000000..4471af1439 --- /dev/null +++ b/src/next/types/constant-def.ts @@ -0,0 +1,85 @@ +/* eslint-disable no-inner-declarations */ +import * as Ast from "@/next/ast"; +import { assignType, decodeTypeLazy } from "@/next/types/type"; +import { decodeExpr } from "@/next/types/expression"; +import { evalExpr } from "@/next/types/expr-eval"; +import { emptyTypeParams } from "@/next/types/type-params"; + +export function decodeConstantDef( + Lazy: Ast.ThunkBuilder, + defLoc: Ast.Loc, + typeParams: Ast.CTypeParams, + { type, initializer }: Ast.ConstantDef, + scopeRef: () => Ast.CSource, + selfType: undefined | Ast.SelfType, +): [Ast.Thunk, Ast.Thunk] { + if (type) { + // if there is an ascribed type, that's the one we return + const ascribedType = decodeTypeLazy(Lazy, typeParams, type, scopeRef); + // also we have to check that it's the expected type prior to + // evaluating the expression + function* evaluate(Lazy: Ast.ThunkBuilder) { + const expr = yield* decodeExpr( + Lazy, + typeParams, + initializer, + scopeRef, + selfType, + new Map(), + ); + const computed = expr.value.computedType; + const ascribed = yield* ascribedType(); + yield* assignType( + defLoc, + emptyTypeParams, + ascribed, + computed, + false, + ); + return yield* evalExpr(expr.value, scopeRef); + } + const lazyExpr = Lazy({ + loc: defLoc, + context: [Ast.TEText("evaluating expression")], + recover: undefined, + callback: evaluate, + }); + return [ascribedType, lazyExpr]; + } else { + // first we decode expression + const expr = Lazy({ + callback: (Lazy) => + decodeExpr( + Lazy, + typeParams, + initializer, + scopeRef, + selfType, + new Map(), + ), + context: [Ast.TEText("parsing expression")], + loc: defLoc, + recover: undefined, + }); + // then we evaluate it without any other checks + const lazyExpr = Lazy({ + callback: function* () { + const ast = yield* expr(); + return ast && (yield* evalExpr(ast.value, scopeRef)); + }, + context: [Ast.TEText("evaluating expression")], + loc: defLoc, + recover: undefined, + }); + // resulting type is whatever the type expression has + const computedType = Lazy({ + callback: function* () { + return (yield* expr())?.value.computedType ?? Ast.CTRecover(); + }, + context: [], + loc: defLoc, + recover: Ast.CTRecover(), + }); + return [computedType, lazyExpr]; + } +} diff --git a/src/next/types/constants.ts b/src/next/types/constants.ts new file mode 100644 index 0000000000..fe418aa20b --- /dev/null +++ b/src/next/types/constants.ts @@ -0,0 +1,111 @@ +/* eslint-disable require-yield */ +import * as Ast from "@/next/ast"; +import type { TactSource } from "@/next/imports/source"; +import { builtinFunctions } from "@/next/types/builtins"; +import { decodeConstantDef } from "@/next/types/constant-def"; +import { emptyTypeParams } from "@/next/types/type-params"; + +const errorKind = "function"; + +export function* decodeConstants( + Lazy: Ast.ThunkBuilder, + imported: readonly Ast.SourceCheckResult[], + source: TactSource, + scopeRef: () => Ast.CSource, +): Ast.Log>> { + // imported + const importedSigs = imported.flatMap(({ globals, importedBy }) => + [...globals.constants].map( + ([name, s]) => + [ + name, + Ast.Decl(s.decl, Ast.ViaImport(importedBy, s.via)), + ] as const, + ), + ); + // deduplicate diamond imports + const filteredImports: (readonly [string, Ast.Decl])[] = []; + const map: Map = new Map(); + for (const [name, decl] of importedSigs) { + const prevSource = map.get(name); + if (typeof prevSource === 'undefined' || decl.via.source !== prevSource) { + filteredImports.push([name, decl]); + map.set(name, decl.via.source); + } + } + // merge + const allConstSigs = [ + ...filteredImports, + // local + ...(yield* Ast.mapLog(source.items.constants, function* (c) { + return [ + c.name.text, + Ast.Decl( + yield* decodeConstant(Lazy, c, scopeRef), + Ast.ViaOrigin(c.loc, source), + ), + ] as const; + })), + ]; + // remove builtins + const filteredSigs = yield* Ast.filterLog( + allConstSigs, + function* ([name, { via }]) { + const isBuiltin = builtinFunctions.has(name); + if (isBuiltin) { + yield Ast.ERedefine(errorKind, name, Ast.ViaBuiltin(), via); + } + return !isBuiltin; + }, + ); + return yield* Ast.toMap(errorKind, filteredSigs); +} + +function* decodeConstant( + Lazy: Ast.ThunkBuilder, + constant: Ast.Constant, + scopeRef: () => Ast.CSource, +) { + const { init, loc } = constant; + if (init.kind === "constant_decl") { + yield ETopLevelDecl(loc); + const type = Lazy({ + loc: constant.loc, + context: [ + Ast.TEText("defining constant"), + Ast.TECode(constant.loc), + ], + recover: Ast.CTRecover(), + callback: function* () { + return Ast.CTRecover(); + }, + }); + const expr = Lazy({ + loc: constant.loc, + context: [ + Ast.TEText("defining constant"), + Ast.TECode(constant.loc), + ], + recover: Ast.VNumber(0n, constant.loc), + callback: function* () { + return Ast.VNumber(0n, constant.loc); + }, + }); + return Ast.CConstant(expr, type); + } else { + const [type, expr] = decodeConstantDef( + Lazy, + loc, + emptyTypeParams, + init, + scopeRef, + undefined, + ); + return Ast.CConstant(expr, type); + } +} + +const ETopLevelDecl = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Top-level constant must have a body`), +); diff --git a/src/next/types/contract.ts b/src/next/types/contract.ts new file mode 100644 index 0000000000..2bb7b7e2f0 --- /dev/null +++ b/src/next/types/contract.ts @@ -0,0 +1,352 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { throwInternal } from "@/error/errors"; +import { getFieldishGeneral } from "@/next/types/fields"; +import { getInheritedTraits } from "@/next/types/traits-scope"; +import { getMethodsGeneral } from "@/next/types/methods"; +import { getReceivers } from "@/next/types/receivers"; +import { decodeDealiasTypeLazy, decodeTypeLazy } from "@/next/types/type"; +import { decodeParams } from "@/next/types/type-fn"; +import { decodeStatementsLazy } from "@/next/types/statements"; +import { Void } from "@/next/types/builtins"; +import { emptyTypeParams } from "@/next/types/type-params"; + +export function* decodeContract( + Lazy: Ast.ThunkBuilder, + contract: Ast.Contract, + scopeRef: () => Ast.CSource, +) { + const { name, attributes, declarations, init } = contract; + const { constants, fields, methods, receivers } = declarations; + + // here we have a strange loop + // to get fields in contentLazy we need contract parameters from initLazy + // to compute fields for empty init, we need to know contentLazy + // to check init body in initLazy we have to know `self` from contentLazy + + const decodedInit = yield* decodeInit( + Lazy, + contract.loc, + () => selfType, + init, + () => contentLazy, + scopeRef, + ); + + // delayed until we get all traits and init + const contentLazy: Ast.Thunk = Lazy({ + callback: function* (Lazy) { + const traits = yield* getInheritedTraits(contract.traits, scopeRef); + + // const contentRef = () => content; + const content: Ast.CContractMembers = { + fieldish: yield* getFieldishFromContract( + Lazy, + contractSig, + name, + traits, + decodedInit, + constants, + fields, + scopeRef, + ), + methods: yield* getMethodsFromContract( + Lazy, + contractSig, + name, + traits, + methods, + scopeRef, + ), + receivers: yield* getReceivers( + Lazy, + () => selfType, + name, + traits, + receivers, + scopeRef, + ), + }; + + return content; + }, + context: [Ast.TEText("checking scope of contract")], + loc: contract.loc, + recover, + }); + + const contractSig = Ast.CContract(attributes, decodedInit, contentLazy); + + const selfType = Ast.SVTRef( + contract.name, + contractSig, + [], + contract.loc, + ); + + return contractSig; +} + +function* decodeInit( + Lazy: Ast.ThunkBuilder, + contractLoc: Ast.Loc, + selfTypeRef: () => Ast.SelfType, + init: Ast.Init | undefined, + contentLazy: () => Ast.Thunk, + scopeRef: () => Ast.CSource, +): Ast.Log { + if (!init) { + // no init + const lazyInit = Lazy({ + callback: function* () { + const order: string[] = []; + const map: Map< + string, + Ast.Thunk> + > = new Map(); + const { fieldish } = yield* contentLazy()(); + for (const name of fieldish.order) { + const f = fieldish.map.get(name); + if (!f) { + return throwInternal("Missing field"); + } + if (f.decl.kind === "field") { + const init = f.decl.init; + if (init) { + order.push(name); + map.set(name, init); + } else { + yield ENoInitializerEmpty(f.via.defLoc); + } + } + } + return Ast.Ordered(order, map); + }, + context: [Ast.TEText("computing parameters of empty init")], + loc: contractLoc, + recover: undefined, + }); + return Ast.CInitEmpty(lazyInit); + } else if (init.kind === "init_params") { + const order: string[] = []; + const paramMap: Map = new Map(); + for (const param of init.params) { + const name = param.name.text; + const prev = paramMap.get(name); + if (prev) { + yield EDuplicateParam(name, prev.loc, param.loc); + } else { + order.push(name); + paramMap.set(name, param); + } + } + + const map: Map = new Map(); + for (const [name, param] of paramMap) { + const decoded = decodeTypeLazy( + Lazy, + emptyTypeParams, + param.type, + scopeRef, + ); + if (!param.initializer) { + yield ENoInitializerParams(param.loc); + } + map.set(name, Ast.CInitParam(decoded, undefined, param.loc)); + } + return Ast.CInitSimple(Ast.Ordered(order, map), init.loc); + } else { + const { params, statements } = init; + + const decodedParams = yield* decodeParams((type) => { + return decodeDealiasTypeLazy(Lazy, emptyTypeParams, type, scopeRef); + }, params); + + const body = decodeStatementsLazy( + Lazy, + init.loc, + statements, + () => Ast.CTMethod( + true, + emptyTypeParams, + selfTypeRef(), + decodedParams, + Lazy({ + callback: function* () { + return Void; + }, + context: [], + loc: init.loc, + recover: Void, + }), + ), + true, + scopeRef, + ); + + return Ast.CInitFn(decodedParams, body); + } +} +const EDuplicateParam = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText(`Contract parameter ${name} was already defined`), + Ast.TEText(`New definition:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); +const ENoInitializerParams = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Contract parameters cannot have an initializer`), +); +const ENoInitializerEmpty = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText( + `When there is no init() or contract parameters, all fields must have an initializer`, + ), +); + +function* getMethodsFromContract( + Lazy: Ast.ThunkBuilder, + contractSig: Ast.CContract, + typeName: Ast.TypeId, + traits: readonly Ast.Decl[], + methods: readonly Ast.Method[], + scopeRef: () => Ast.CSource, +): Ast.Log>>> { + const res = yield* getMethodsGeneral( + Lazy, + contractSig, + typeName, + traits, + methods, + scopeRef, + ); + + const map: Map>> = new Map(); + for (const [name, { via, decl: method }] of res) { + if (method.body) { + // have to recreate DeclMem, because TS doesn't + // narrow here + map.set(name, Ast.DeclMem({ ...method, body: method.body }, via)); + } else { + // field/constant doesn't have initializer + yield EAbstract("method", name, via); + } + } + + return map; +} + +function* getFieldishFromContract( + Lazy: Ast.ThunkBuilder, + contractSig: Ast.CContract, + typeName: Ast.TypeId, + traits: readonly Ast.Decl[], + init: Ast.CInit, + constants: readonly Ast.FieldConstant[], + fields: readonly Ast.FieldDecl[], + scopeRef: () => Ast.CSource, +): Ast.Log< + Ast.Ordered>>>> +> { + const res = yield* getFieldishGeneral( + Lazy, + contractSig, + typeName, + traits, + constants, + fields, + scopeRef, + ); + + const order: string[] = []; + const map: Map< + string, + Ast.DeclMem>>> + > = new Map(); + for (const name of res.order) { + const field = res.map.get(name); + if (!field) { + return throwInternal("getFieldishTrait lost fields"); + } + if (field.decl.init) { + // have to recreate DeclMem, because TS doesn't + // narrow here + map.set( + name, + Ast.DeclMem( + { ...field.decl, init: field.decl.init }, + field.via, + ), + ); + } else { + // field/constant doesn't have initializer + yield EAbstract("field", name, field.via); + } + } + + if (init.kind === "simple") { + const map: Map< + string, + Ast.DeclMem>>> + > = new Map(); + if (order.length !== 0) { + yield EFieldsTwice(init.loc); + } + for (const [name, param] of init.fill.map) { + order.push(name); + map.set( + name, + Ast.DeclMem( + Ast.CField(param.type, param.init), + Ast.ViaMemberOrigin(typeName.text, param.loc), + ), + ); + } + return { order: init.fill.order, map }; + } else { + return { order, map }; + } +} +const EFieldsTwice = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Cannot define other fields when using contract parameters`), +); +const EAbstract = ( + kind: string, + name: string, + next: Ast.ViaMember, +) => Ast.TcError( + next.defLoc, + Ast.TEText(`Contract ${kind} "${name}" must have an initializer`), + Ast.TEViaMember(next), +); + +const recover: Ast.CContractMembers = { + fieldish: Ast.Ordered([], new Map()), + methods: new Map(), + receivers: { + bounce: { + message: [], + messageAny: undefined, + }, + external: { + empty: undefined, + message: [], + messageAny: undefined, + stringAny: undefined, + }, + internal: { + empty: undefined, + message: [], + messageAny: undefined, + stringAny: undefined, + }, + }, +}; diff --git a/src/next/types/effects.ts b/src/next/types/effects.ts new file mode 100644 index 0000000000..0ba60a6899 --- /dev/null +++ b/src/next/types/effects.ts @@ -0,0 +1,73 @@ +import * as Ast from "@/next/ast"; +// import { hasStorageAccess } from "@/next/types/expression"; + +// op read/write throw +// 42 empty false false +// a ? b : c a prod (b sum c) a | b | c a | (b & c) +// f(a, b) a prod b a | b a | b +// a && b a cond b a | b a +// a || b a cond b a | b a + +// true true a b +// true false a b +// false true a +// false false a + +export const emptyEff = Ast.Effects( + false, + false, + false, + new Set(), +); + +export const allEff = ( + effs: readonly Ast.Effects[], +) => Ast.Effects( + effs.some(eff => eff.mayRead), + effs.some(eff => eff.mayWrite), + // if any of args throws, expr throws + effs.some(eff => eff.mustThrow), + new Set(effs.flatMap(eff => [...eff.mustSetSelf])), +); + +export const anyEff = ( + effs: readonly Ast.Effects[], +) => Ast.Effects( + effs.some(eff => eff.mayRead), + effs.some(eff => eff.mayWrite), + // if all of branches throw, expr throws + effs.every(eff => eff.mustThrow), + new Set(effs.flatMap(eff => [...eff.mustSetSelf])), +); + +export const shortCircuitEff = ( + left: Ast.Effects, + right: Ast.Effects, +) => Ast.Effects( + left.mayRead || right.mayRead, + left.mayWrite || right.mayWrite, + // only if condition throws, we know it must throw + // if condition doesn't throw, we can never evaluate second arg, + // and it's not guaranteed to throw + left.mustThrow, + new Set([...left.mustSetSelf, ...right.mustSetSelf]), +); + +export const exitEff = (eff: Ast.Effects): Ast.Effects => ({ ...eff, mustThrow: true }); +export const assignEff = (eff: Ast.Effects): Ast.Effects => ({ ...eff, mustThrow: true }); + +export function hasStorageAccess(node: Ast.CExpr, selfType: Ast.SelfType | undefined): boolean { + // looking for `self.x.y.z` + if (node.kind === 'field_access') { + return hasStorageAccess(node.aggregate, selfType); + } else if (node.kind === 'self') { + return Boolean( + selfType && + selfType.kind === 'type_ref' && + (selfType.type.kind === 'contract' || selfType.type.kind === 'trait') + ); + } else { + return false; + } +} + diff --git a/src/next/types/expr-eval.ts b/src/next/types/expr-eval.ts new file mode 100644 index 0000000000..ce6f58c79e --- /dev/null +++ b/src/next/types/expr-eval.ts @@ -0,0 +1,10 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; + +export function* evalExpr( + expr: Ast.CExpr, + scopeRef: () => Ast.CSource, +): Ast.Log { + return Ast.VNumber(0n, expr.loc); +} diff --git a/src/next/types/expression.ts b/src/next/types/expression.ts new file mode 100644 index 0000000000..a7c9e25851 --- /dev/null +++ b/src/next/types/expression.ts @@ -0,0 +1,891 @@ +/* eslint-disable require-yield */ +import * as Ast from "@/next/ast"; +import { throwInternal } from "@/error/errors"; +import { + Bool, + builtinBinary, + builtinFunctions, + builtinUnary, + getStaticBuiltin, + StateInit, + stateInitFields, +} from "@/next/types/builtins"; +import { + assignType, + dealiasType, + decodeDealiasTypeLazy, + decodeTypeLazy, + decodeTypeMap, + checkFnCall, + instantiateStruct, + checkFnCallWithArgs, + mgu, + lookupMethod, +} from "@/next/types/type"; +import { convertValueToExpr } from "@/next/types/value"; +import { emptyTypeParams } from "@/next/types/type-params"; +import { emptyEff, allEff, shortCircuitEff, anyEff, hasStorageAccess } from "@/next/types/effects"; + +type Decode = ( + node: T, + ctx: Context, +) => Ast.Log>; + +type Result = { + readonly value: U; + readonly eff: Ast.Effects; +} +const Result = ( + value: U, + eff: Ast.Effects, +): Result => ({ value, eff }); + +type Context = { + readonly Lazy: Ast.ThunkBuilder; + readonly scopeRef: () => Ast.CSource; + readonly selfType: Ast.SelfType | undefined; + readonly typeParams: Ast.CTypeParams; + readonly localScopeRef: ReadonlyMap; +}; + +export function* decodeExpr( + Lazy: Ast.ThunkBuilder, + typeParams: Ast.CTypeParams, + node: Ast.Expression, + scopeRef: () => Ast.CSource, + selfType: Ast.SelfType | undefined, + localScopeRef: ReadonlyMap, +) { + const result = yield* decodeExprCtx(node, { + Lazy, + typeParams, + scopeRef, + selfType, + localScopeRef, + }); + return { value: result.value, eff: result.eff }; +} + +export const decodeExprCtx: Decode = ( + node, + ctx, +) => { + switch (node.kind) { + case "null": + return decodeNullCons(node, ctx); + case "unit": + return decodeUnitCons(node, ctx); + case "string": + return decodeStringCons(node, ctx); + case "number": + return decodeNumberCons(node, ctx); + case "boolean": + return decodeBooleanCons(node, ctx); + case "tuple": + return decodeTupleCons(node, ctx); + case "tensor": + return decodeTensorCons(node, ctx); + case "map_literal": + return decodeMapCons(node, ctx); + case "set_literal": + return decodeSetCons(node, ctx); + case "struct_instance": + return decodeStructCons(node, ctx); + + case "var": + return decodeVar(node, ctx); + case "op_binary": + return decodeBinary(node, ctx); + case "op_unary": + return decodeUnary(node, ctx); + case "conditional": + return decodeTernary(node, ctx); + case "method_call": + return decodeMethodCall(node, ctx); + case "static_call": + return decodeFunctionCall(node, ctx); + case "static_method_call": + return decodeStaticMethodCall(node, ctx); + case "field_access": + return decodeFieldAccess(node, ctx); + case "init_of": + return decodeInitOf(node, ctx); + case "code_of": + return decodeCodeOf(node, ctx); + } +}; + +const decodeNullCons: Decode = function* (node) { + return Result(Ast.CNull(Ast.TBasic(Ast.TNull(node.loc), node.loc), node.loc), emptyEff); +}; + +const decodeUnitCons: Decode = function* (node) { + return Result(Ast.CUnit(Ast.TBasic(Ast.TUnit(node.loc), node.loc), node.loc), emptyEff); +}; + +const decodeStringCons: Decode = function* (node) { + return Result(Ast.CString(node.value, Ast.TBasic(Ast.TString(node.loc), node.loc), node.loc), emptyEff); +}; + +const decodeNumberCons: Decode = function* (node) { + return Result(Ast.DNumber( + node.base, + node.value, + Ast.TBasic(Ast.TInt(Ast.IFInt("signed", 257, node.loc), node.loc), node.loc), + node.loc, + ), emptyEff); +}; + +const decodeBooleanCons: Decode = function* (node) { + return Result(Ast.CBoolean(node.value, Ast.TBasic(Ast.TBool(node.loc), node.loc), node.loc), emptyEff); +}; + +const decodeTupleCons: Decode = function* (node, ctx) { + const children = yield* Ast.mapLog(node.children, (child) => + decodeExprCtx(child, ctx), + ); + const exprs = children.map((child) => child.value); + const argTypes = exprs.map((expr) => expr.computedType); + const newEff = allEff(children.map((child) => child.eff)); + return Result(Ast.CTuple(exprs, Ast.CTTuple(argTypes, node.loc), node.loc), newEff); +}; + +const decodeTensorCons: Decode = function* ( + node, + ctx, +) { + const children = yield* Ast.mapLog(node.children, (child) => + decodeExprCtx(child, ctx), + ); + const exprs = children.map((child) => child.value); + const argTypes = exprs.map((expr) => expr.computedType); + const newEff = allEff(children.map((child) => child.eff)); + return Result(Ast.CTensor(exprs, Ast.CTTensor(argTypes, node.loc), node.loc), newEff); +}; + +const decodeMapCons: Decode = function* ( + node, + ctx, +) { + const ascribed = yield* decodeTypeMap( + ctx.typeParams, + node.type, + ctx.scopeRef, + ); + const fields = yield* Ast.mapLog(node.fields, function* (field) { + const key = yield* decodeExprCtx(field.key, ctx); + yield* assignType( + field.key.loc, + emptyTypeParams, + ascribed.key, + key.value.computedType, + false, + ); + const value = yield* decodeExprCtx(field.value, ctx); + yield* assignType( + field.value.loc, + emptyTypeParams, + ascribed.value, + value.value.computedType, + false, + ); + return Result( + Ast.CMapField(key.value, value.value), + allEff([key.eff, value.eff]), + ); + }); + + return Result( + Ast.CMapLiteral( + ascribed, + fields.map(field => field.value), + node.loc, + ), + allEff(fields.map(field => field.eff)), + ); +}; + +const decodeSetCons: Decode = function* () { + return throwInternal("Set literals must have been declined before"); +}; + +const decodeStructCons: Decode = + function* (node, ctx) { + const typeArgs = yield* Ast.mapLog(node.typeArgs, function* (arg) { + return yield* decodeTypeLazy( + ctx.Lazy, + ctx.typeParams, + arg, + ctx.scopeRef, + )(); + }); + const instance = yield* instantiateStruct( + node.type, + typeArgs, + ctx.typeParams, + ctx.scopeRef, + ); + // see checkFields in statement.ts + const fields = yield* checkFields( + instance?.fields, + node.args, + node.loc, + ctx, + ); + return Result( + Ast.CStructCons( + fields.value, + instance?.type ?? Ast.CTRecover(), + node.loc, + ), + fields.eff, + ); + }; +function* checkFields( + typeFields: Ast.Ordered | undefined, + args: readonly Ast.StructFieldInitializer[], + loc: Ast.Loc, + ctx: Context, +): Ast.Log>>> { + const map: Map> = new Map(); + for (const arg of args) { + const fieldName = arg.field.text; + + const prev = map.get(fieldName); + if (prev) { + yield EDuplicateField(fieldName, prev.value.loc, arg.loc); + continue; + } + const expr = yield* decodeExprCtx(arg.initializer, ctx); + + if (typeFields) { + const typeField = typeFields.map.get(fieldName); + if (typeField) { + yield* assignType( + expr.value.loc, + emptyTypeParams, + yield* typeField.type(), + expr.value.computedType, + false, + ); + } else { + yield ENoSuchField(fieldName, arg.loc); + } + } + + map.set(fieldName, expr); + } + + if (typeFields) { + const effects: Ast.Effects[] = []; + const result: Map< + string, + Ast.Recover + > = new Map(); + for (const fieldName of typeFields.order) { + const field = typeFields.map.get(fieldName); + if (!field) { + return throwInternal("Ordered<>: lost fields"); + } + const fieldInst = map.get(fieldName); + if (fieldInst) { + effects.push(fieldInst.eff); + result.set(fieldName, fieldInst.value); + } else if (field.init) { + const value = yield* field.init(); + if (value) { + const inst = convertValueToExpr(value); + result.set(fieldName, inst); + } else { + result.set(fieldName, undefined); + } + } else { + yield EMissingField(fieldName, loc); + result.set(fieldName, undefined); + } + } + return Result( + Ast.Ordered(typeFields.order, result), + allEff(effects) + ); + } else { + return Result( + Ast.Ordered( + [...map.keys()], + new Map([...map].map(([name, { value }]) => [name, value])), + ), + allEff([...map].map(([, { eff }]) => eff)), + ); + } +} +const EMissingField = (name: string, prev: Ast.Loc) => Ast.TcError( + prev, + Ast.TEText(`Value for field "${name}" is missing`), + Ast.TECode(prev), +); +const ENoSuchField = (name: string, next: Ast.Loc) => Ast.TcError( + next, + Ast.TEText(`There is no field "${name}"`), Ast.TECode(next), +); +const EDuplicateField = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + prev, + Ast.TEText(`Duplicate field "${name}"`), + Ast.TEText(`Defined at:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); + +const decodeVar: Decode = function* (node, ctx) { + if (node.name !== "self") { + const type = yield* lookupVar(node.name, node.loc, ctx); + return Result( + Ast.CVar(node.name, type, node.loc), + emptyEff, + ); + } + if (ctx.selfType) { + return Result( + Ast.CSelf(ctx.selfType, node.loc), + emptyEff, + ); + } + yield ENoSelf(node.loc); + return Result( + Ast.CVar(node.name, Ast.TBasic(Ast.TNull(node.loc), node.loc), node.loc), + emptyEff, + ); +}; +const ENoSelf = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`"self" is not allowed here`), +); +function* lookupVar( + name: string, + loc: Ast.Loc, + ctx: Context, +): Ast.Log { + const local = ctx.localScopeRef.get(name); + if (local) { + const [type] = local; + return type; + } + const global = ctx.scopeRef().constants.get(name); + if (global) { + return yield* global.decl.type(); + } + yield EUndefined(name, loc); + return Ast.CTRecover(); +} +const EUndefined = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Variable "${name}" not defined`), +); + +const decodeBinary: Decode = function* ( + node, + ctx, +) { + const left = yield* decodeExprCtx(node.left, ctx); + const right = yield* decodeExprCtx(node.right, ctx); + const fnType = builtinBinary.get(node.op); + if (!fnType) { + return throwInternal("Builtin operator is not in the map"); + } + const { returnType, typeArgMap } = yield* checkFnCall(node.loc, fnType, [ + [left.value.loc, left.value.computedType], + [right.value.loc, right.value.computedType], + ]); + if ((node.op === "==" || node.op === "!=") && returnType.kind !== 'recover') { + const typeArg = typeArgMap.get("T"); + if (!typeArg) { + return throwInternal( + "getCallResult produced incorrect substitution", + ); + } + if (typeArg.kind !== "recover" && !supportsEquality(typeArg)) { + yield ENoEquality(node.loc); + } + } + const newEff = node.op === '&&' || node.op === '||' + ? shortCircuitEff(left.eff, right.eff) + : allEff([left.eff, right.eff]); + return Result( + Ast.COpBinary( + node.op, + left.value, + right.value, + typeArgMap, + returnType, + node.loc, + ), + newEff, + ); +}; +const ENoEquality = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Equality on this type is not supported`), +); +const supportsEquality = (_common: Ast.CType): boolean => { + return true; // FIXME + // switch (common.kind) { + // case "map_type": { + // return true; + // } + // case "TypeMaybe": { + // return supportsEquality(common.type); + // } + // case "recover": + // case "type_ref": + // case "TypeAlias": + // case "TypeParam": + // case "TypeBounced": + // case "tuple_type": + // case "tensor_type": { + // return false; + // } + // case "basic": { + // return supportsEqualityBasic(common.type); + // } + // } +}; +// const supportsEqualityBasic = (common: Ast.BasicType): boolean => { +// switch (common.kind) { +// case "unit_type": +// case "TyInt": +// case "TySlice": +// case "TyCell": +// case "TypeNull": +// case "TypeBool": +// case "TypeAddress": +// case "TypeString": { +// return true; +// } +// case "TypeVoid": +// case "TyBuilder": +// case "TypeStateInit": +// case "TypeStringBuilder": { +// return false; +// } +// } +// }; + + +const decodeUnary: Decode = function* (node, ctx) { + const operand = yield* decodeExprCtx(node.operand, ctx); + const fnType = builtinUnary.get(node.op); + if (!fnType) { + return throwInternal("Builtin operator is not in the map"); + } + const { returnType, typeArgMap } = yield* checkFnCall(node.loc, fnType, [ + [operand.value.loc, operand.value.computedType], + ]); + + return Result( + Ast.COpUnary( + node.op, + operand.value, + typeArgMap, + returnType, + node.loc, + ), + operand.eff, + ); +}; + +const decodeTernary: Decode = function* ( + node, + ctx, +) { + const condition = yield* decodeExprCtx(node.condition, ctx); + yield* assignType( + condition.value.loc, + emptyTypeParams, + Bool, + condition.value.computedType, + false, + ); + const thenBranch = yield* decodeExprCtx(node.thenBranch, ctx); + const elseBranch = yield* decodeExprCtx(node.elseBranch, ctx); + const commonType = yield* mgu( + thenBranch.value.computedType, + elseBranch.value.computedType, + node.loc, + ); + return Result( + Ast.CConditional( + condition.value, + thenBranch.value, + elseBranch.value, + commonType, + node.loc, + ), + allEff([ + condition.eff, + anyEff([ + thenBranch.eff, + elseBranch.eff, + ]), + ]), + ); +}; + +const decodeMethodCall: Decode = function* ( + node, + ctx, +) { + const self = yield* decodeExprCtx(node.self, ctx); + const args = yield* Ast.mapLog(node.args, (arg) => decodeExprCtx(arg, ctx)); + + const { typeDecls, extensions } = ctx.scopeRef(); + const { returnType, typeArgMap, mutates } = yield* lookupMethod( + ctx.Lazy, + self.value.computedType, + node.method, + args.map((child) => [child.value.loc, child.value.computedType]), + typeDecls, + extensions, + ); + + const isCallOnStorage = hasStorageAccess(self.value, ctx.selfType); + + const selfArgsEff = allEff([self.eff, ...args.map(arg => arg.eff)]); + + return Result( + Ast.CMethodCall( + self.value, + node.method, + args.map(arg => arg.value), + typeArgMap, + returnType, + node.loc, + ), + { + mayRead: isCallOnStorage || selfArgsEff.mayRead, + mayWrite: mutates && isCallOnStorage || selfArgsEff.mayWrite, + mustThrow: selfArgsEff.mustThrow, + mustSetSelf: new Set(), + }, + ); +}; + +const decodeFunctionCall: Decode< + Ast.StaticCall, + Ast.CStaticCall | Ast.CNumber +> = function* (node, ctx) { + const name = node.function; + + const args = yield* Ast.mapLog(node.args, (arg) => decodeExprCtx(arg, ctx)); + + if (name.text === "sha256") { + const [arg] = args; + const int = Ast.TBasic(Ast.TInt(Ast.IFInt("signed", 257, node.loc), node.loc), node.loc); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if ( + args.length !== 1 || + !arg || + (arg.value.computedType.kind !== "basic") || + ( + arg.value.computedType.type.kind !== "TySlice" && + arg.value.computedType.type.kind !== "TypeString" + ) + ) { + yield EMismatchSha256(node.loc); + return Result( + Ast.DNumber("10", 0n, int, node.loc), + emptyEff, + ); + } else { + return Result( + Ast.CStaticCall(name, new Map(), [arg.value], int, node.loc), + arg.eff, + ); + } + } + + const builtinFnType = builtinFunctions.get(name.text); + const globalFnType = ctx.scopeRef().functions.get(name.text)?.decl.type; + const fnType = builtinFnType ?? globalFnType; + + const { returnType, typeArgMap } = yield* checkFnCallWithArgs( + ctx.Lazy, + node.function.loc, + fnType, + yield* Ast.mapLog(node.typeArgs, function* (arg) { + return yield* decodeDealiasTypeLazy( + ctx.Lazy, + ctx.typeParams, + arg, + ctx.scopeRef, + )(); + }), + args.map((child) => [child.value.loc, child.value.computedType]), + ); + + const exprs = args.map(arg => arg.value); + const newEffs = allEff(args.map(arg => arg.eff)); + + if (name.text === "throw" || name.text === "nativeThrow") { + return Result( + Ast.CStaticCall(name, typeArgMap, exprs, returnType, node.loc), + { + ...newEffs, + mustThrow: true, + }, + ); + } else { + return Result(Ast.CStaticCall(name, typeArgMap, exprs, returnType, node.loc), newEffs); + } +}; +const EMismatchSha256 = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`sha256() takes either Slice or String`), +); + +const decodeStaticMethodCall: Decode< + Ast.StaticMethodCall, + Ast.CStaticMethodCall | Ast.CNull +> = function* (node, ctx) { + if (node.typeArgs.length > 0) { + yield EFunctionArity(node.loc); + } + const args = yield* Ast.mapLog(node.args, (arg) => decodeExprCtx(arg, ctx)); + const selfDecl = ctx.scopeRef().typeDecls.get(node.self.text); + if (!(selfDecl?.decl.kind === "struct" || selfDecl?.decl.kind === "message")) { + yield EUndefinedStatic(node.function.text, node.loc); + return Result(Ast.CNull(Ast.TBasic(Ast.TNull(node.loc), node.loc), node.loc), emptyEff); + } + const builtins = getStaticBuiltin( + Ast.CTRef(node.self, selfDecl.decl, [], node.loc), + ); + const builtin = builtins.get(node.function.text); + if (!builtin) { + yield EUndefinedStatic(node.function.text, node.loc); + return Result(Ast.CNull(Ast.TBasic(Ast.TNull(node.loc), node.loc), node.loc), emptyEff); + } + const { returnType, typeArgMap } = yield* checkFnCallWithArgs( + ctx.Lazy, + node.loc, + builtin, + [], + args.map((child) => [child.value.loc, child.value.computedType]), + ); + const newEffs = allEff(args.map(arg => arg.eff)); + return Result( + Ast.CStaticMethodCall( + node.self, + typeArgMap, + node.function, + args.map(arg => arg.value), + returnType, + node.loc, + ), + newEffs, + ); +}; +const EUndefinedStatic = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Static method ${name} doesn't exist`), +); +const EFunctionArity = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Function doesn't take any generic arguments`), +); + +const decodeFieldAccess: Decode = function* ( + node, + ctx, +) { + const expr = yield* decodeExprCtx(node.aggregate, ctx); + const selfType = expr.value.computedType; + const returnType = yield* lookupField(selfType, node.field, ctx.scopeRef); + return Result( + Ast.CFieldAccess(expr.value, node.field, returnType, node.loc), + { + ...expr.eff, + mayRead: hasStorageAccess(expr.value, ctx.selfType) || expr.eff.mayRead, + }, + ); +}; + +function* lookupField( + selfType: Ast.CType, + fieldName: Ast.Id, + scopeRef: () => Ast.CSource, +): Ast.Log { + switch (selfType.kind) { + case "type_ref": { + const decl = selfType.type; + switch (decl.kind) { + case "contract": + case "trait": { + const fields = (yield* decl.content()).fieldish; + const field = fields.map.get(fieldName.text); + if (!field) { + yield ENoSuchField(fieldName.text, fieldName.loc); + return Ast.CTRecover(); + } + return yield* field.decl.type(); + } + case "struct": + case "message": { + const field = decl.fields.map.get(fieldName.text); + if (!field) { + yield ENoSuchField(fieldName.text, fieldName.loc); + return Ast.CTRecover(); + } + return yield* field.type(); + } + case "union": { + yield ENoSuchField(fieldName.text, fieldName.loc); + return Ast.CTRecover(); + } + } + // linter asks for this unreachable code + return throwInternal("Not all ref cases handled"); + } + case "TypeMaybe": { + const type = yield* lookupField(selfType.type, fieldName, scopeRef); + if (type.kind === "recover") { + return type; + } else { + return Ast.CTMaybe(type, fieldName.loc); + } + } + case "TypeBounced": { + const decl = scopeRef().typeDecls.get(selfType.name.text); + if (!decl || decl.decl.kind !== "message") { + yield ENoSuchField(fieldName.text, fieldName.loc); + return Ast.CTRecover(); + } + const field = decl.decl.fields.map.get(fieldName.text); + if (!field) { + yield ENoSuchField(fieldName.text, fieldName.loc); + return Ast.CTRecover(); + } + return yield* field.type(); + } + case "recover": { + return Ast.CTRecover(); + } + case "TypeAlias": { + const type = yield* dealiasType(selfType, scopeRef); + return yield* lookupField(type, fieldName, scopeRef); + } + case "basic": { + if (selfType.type.kind === 'TypeStateInit') { + const type = stateInitFields.get(fieldName.text); + if (type) { + return type; + } + } + yield ENoSuchField(fieldName.text, fieldName.loc); + return Ast.CTRecover(); + } + case "TypeParam": + case "map_type": + case "tuple_type": + case "tensor_type": { + yield ENoSuchField(fieldName.text, fieldName.loc); + return Ast.CTRecover(); + } + } +} + +const decodeInitOf: Decode = function* (node, ctx) { + const args = yield* Ast.mapLog(node.args, (arg) => decodeExprCtx(arg, ctx)); + const contract = ctx.scopeRef().typeDecls.get(node.contract.text); + if (contract?.decl.kind !== "contract") { + yield ENotContract(node.contract.text, node.loc); + return Result( + Ast.CInitOf( + node.contract, + args.map(arg => arg.value), + StateInit, + node.loc, + ), + allEff(args.map(arg => arg.eff)), + ); + } + + const params = yield* initParams(contract.decl.init); + + yield* checkFnCallWithArgs( + ctx.Lazy, + node.loc, + Ast.CTFunction( + emptyTypeParams, + params, + ctx.Lazy({ + callback: function* () { + return StateInit; + }, + context: [Ast.TEText("checking initOf expression")], + loc: node.loc, + recover: StateInit, + }), + ), + [], + args.map((child) => [child.value.loc, child.value.computedType]), + ); + + return Result( + Ast.CInitOf( + node.contract, + args.map(arg => arg.value), + StateInit, + node.loc, + ), + allEff(args.map(arg => arg.eff)), + ); +}; +function* initParams(init: Ast.CInit) { + switch (init.kind) { + case "function": { + return init.params; + } + case "empty": { + return Ast.CParameters([], new Set()); + } + case "simple": { + const order: Ast.CParameter[] = []; + const set: Set = new Set(); + for (const name of init.fill.order) { + const param = init.fill.map.get(name); + if (!param) { + return throwInternal("Ordered<>: missing param"); + } + set.add(name); + order.push({ + name: Ast.Id(name, param.loc), + type: param.type, + loc: param.loc, + }); + } + return Ast.CParameters(order, set); + } + } +} + +const decodeCodeOf: Decode = function* (node, ctx) { + const contract = ctx.scopeRef().typeDecls.get(node.contract.text); + if (contract?.decl.kind !== "contract") { + yield ENotContract(node.contract.text, node.loc); + } + return Result( + Ast.CCodeOf( + node.contract, + Ast.TBasic(Ast.TCell(Ast.SFDefault(node.loc), node.loc), node.loc), + node.loc, + ), + emptyEff, + ); +}; +const ENotContract = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`"${name}" is not a contract`), +); diff --git a/src/next/types/extensions.ts b/src/next/types/extensions.ts new file mode 100644 index 0000000000..625b875442 --- /dev/null +++ b/src/next/types/extensions.ts @@ -0,0 +1,471 @@ +import * as Ast from "@/next/ast"; +import { zip } from "@/utils/array"; +import { throwInternal } from "@/error/errors"; +import { decodeFnType } from "@/next/types/type-fn"; +import { decodeDealiasTypeLazy } from "@/next/types/type"; +import { decodeBody } from "@/next/types/body"; +import { builtinMethods } from "@/next/types/builtins"; +import type { TactSource } from "@/next/imports/source"; + +export function decodeExtensions( + Lazy: Ast.ThunkBuilder, + imported: readonly Ast.SourceCheckResult[], + source: TactSource, + scopeRef: () => Ast.CSource, +): ReadonlyMap[]>> { + const allExts: Map[]>[]> = + new Map(); + + // imported + for (const { globals, importedBy } of imported) { + for (const [name, lazyExts] of globals.extensions) { + const map = allExts.get(name) ?? []; + allExts.set(name, map); + map.push( + Lazy({ + callback: function* () { + const exts = yield* lazyExts(); + return exts.map((ext) => + Ast.Decl( + ext.decl, + Ast.ViaImport(importedBy, ext.via), + ), + ); + }, + context: [Ast.TEText(`importing extension method ${name}`)], + loc: Ast.Builtin(), + recover: [], + }), + ); + } + } + + // local + for (const ext of source.items.extensions) { + const name = ext.fun.name.text; + const map = allExts.get(name) ?? []; + allExts.set(name, map); + map.push( + Lazy({ + callback: function* (Lazy) { + const decoded = yield* decodeExt(Lazy, ext, scopeRef); + if (!decoded) { + return []; + } + return [ + Ast.Decl(decoded, Ast.ViaOrigin(ext.fun.loc, source)), + ]; + }, + context: [ + Ast.TEText( + `defining extension method ${ext.fun.name.text}`, + ), + ], + loc: ext.fun.loc, + recover: [], + }), + ); + } + + const result: Map[]>> = new Map(); + for (const [name, exts] of allExts) { + // checking method overlap is only possible when all the types + // can be resolved + result.set( + name, + Lazy({ + callback: function* () { + // force all thunks + const all: Ast.Decl[] = []; + for (const lazyExt of exts) { + const exts = yield* lazyExt(); + all.push(...exts); + } + + // check overlap and deduplicate + const prevs: Ast.Decl[] = []; + for (const ext of all) { + const builtin = builtinMethods.get(name); + if (builtin && !isCompatible(builtin, ext.decl.type)) { + yield EMethodOverlap( + name, + Ast.ViaBuiltin(), + ext.via, + ); + continue; + } + if (yield* areCompatible(name, prevs, ext)) { + prevs.push(ext); + } + } + return prevs; + }, + context: [ + Ast.TEText(`merging extensions methods with name ${name}`), + ], + loc: Ast.Builtin(), + recover: [], + }), + ); + } + + return result; +} + +function* decodeExt( + Lazy: Ast.ThunkBuilder, + node: Ast.Extension, + scopeRef: () => Ast.CSource, +) { + const { selfType, mutates, fun } = node; + const { type, body, inline, loc } = fun; + + const decodedFn = yield* decodeFnType(Lazy, type, scopeRef); + + const lazySelf = decodeDealiasTypeLazy( + Lazy, + decodedFn.typeParams, + selfType, + scopeRef, + ); + const self = yield* decodeSelfType(yield* lazySelf(), scopeRef); + + if (!self) { + return undefined; + } + + const methodType = Ast.CTMethod( + mutates, + decodedFn.typeParams, + self, + decodedFn.params, + decodedFn.returnType, + ); + + const decodedBody = yield* decodeBody( + Lazy, + body, + methodType, + loc, + scopeRef, + ); + + return Ast.CExtension(methodType, inline, decodedBody); +} + +function* areCompatible( + name: string, + prevs: readonly Ast.Decl[], + next: Ast.Decl, +): Ast.Log { + for (const prev of prevs) { + const prevType = prev.decl.type; + const nextType = next.decl.type; + // NB! checking by reference, see `toSigDecoded` + if (prevType !== nextType && !isCompatible(prevType, nextType)) { + yield EMethodOverlap(name, prev.via, next.via); + return false; + } + } + return true; +} + +const EMethodOverlap = ( + name: string, + prev: Ast.Via, + next: Ast.ViaUser, +) => Ast.TcError( + Ast.viaToRange(next), + Ast.TEText(`Method "${name}" overlaps previously defined method`), + Ast.TEVia(prev), +); + +function isCompatible( + prev: Ast.CTMethod, + next: Ast.CTMethod, +) { + const prevSelf = prev.self; + const nextSelf = next.self; + return ( + prevSelf.kind !== nextSelf.kind || + (prevSelf.ground === "yes" && + nextSelf.ground === "yes" && + !areEqual(prevSelf, nextSelf)) + ); +} + +function areEqual( + prevSelf: Ast.SelfTypeGround, + nextSelf: Ast.SelfTypeGround, +): boolean { + switch (prevSelf.kind) { + case "basic": { + return prevSelf.kind === nextSelf.kind && + prevSelf.type.kind === nextSelf.type.kind; + } + case "type_ref": { + return ( + prevSelf.kind === nextSelf.kind && + prevSelf.name.text === nextSelf.name.text && + allEqual(prevSelf.typeArgs, nextSelf.typeArgs) + ); + } + case "map_type": { + return ( + prevSelf.kind === nextSelf.kind && + allEqual( + [prevSelf.key, prevSelf.value], + [nextSelf.key, nextSelf.value], + ) + ); + } + case "TypeMaybe": { + return ( + prevSelf.kind === nextSelf.kind && + areEqual(prevSelf.type, prevSelf.type) + ); + } + case "tuple_type": + case "tensor_type": { + return ( + prevSelf.kind === nextSelf.kind && + allEqual(prevSelf.typeArgs, nextSelf.typeArgs) + ); + } + } +} + +function allEqual( + prevs: readonly Ast.SelfTypeGround[], + nexts: readonly Ast.SelfTypeGround[], +): boolean { + return zip(prevs, nexts).every(([prev, next]) => areEqual(prev, next)); +} + +function* decodeSelfType( + type: Ast.CType, + scopeRef: () => Ast.CSource, +): Ast.Log { + switch (type.kind) { + case "recover": { + return undefined; + } + case "type_ref": { + const def = scopeRef().typeDecls.get(type.name.text); + if (!def) { + return throwInternal("Decoder returned broken reference"); + } + switch (def.decl.kind) { + case "alias": { + return throwInternal("Decoder returned broken reference"); + } + case "contract": + case "trait": { + yield ENoMethods("contract", type.loc); + return undefined; + } + case "struct": + case "message": + case "union": { + const allVars = type.typeArgs.filter((arg) => { + return arg.kind === "TypeParam"; + }); + if (type.typeArgs.length === allVars.length) { + const argNames = new Set( + allVars.map((v) => v.name.text), + ); + if (argNames.size !== allVars.length) { + // type variables are not distinct + yield EBadMethodType(type.loc); + return undefined; + } + return Ast.SVTRef( + type.name, + def.decl, + allVars, + type.loc, + ); + } + if (type.typeArgs.length > 0 && allVars.length > 0) { + // has vars, but it's not all the parameters + yield EBadMethodType(type.loc); + return undefined; + } + const ground: Ast.SelfTypeGround[] = []; + for (const arg of type.typeArgs) { + const result = yield* toGroundType(arg, scopeRef); + if (!result) { + yield EBadMethodType(type.loc); + return undefined; + } + ground.push(result); + } + return Ast.SGTRef(type.name, def.decl, ground, type.loc); + } + } + // somehow typescript wants this + return throwInternal("Unknown declaration type"); + } + case "TypeAlias": { + return throwInternal("resolveAliases didn't resolve them"); + } + case "TypeParam": { + yield EBadMethodType(type.loc); + return undefined; + } + case "map_type": { + if ( + type.key.kind === "TypeParam" && + type.value.kind === "TypeParam" + ) { + return Ast.SVTMap(type.key, type.value, type.loc); + } + const ground = yield* toGroundType(type, scopeRef); + if (!ground) { + yield EBadMethodType(type.loc); + return undefined; + } + return ground; + } + case "TypeBounced": { + yield EBadMethodType(type.loc); + return undefined; + } + case "TypeMaybe": { + if (type.type.kind === "TypeParam") { + return Ast.SVTMaybe(type.type, type.loc); + } + const ground = yield* toGroundType(type, scopeRef); + if (!ground) { + yield EBadMethodType(type.loc); + return undefined; + } + return ground; + } + case "tensor_type": + case "tuple_type": { + const mvCons = + type.kind === "tuple_type" ? Ast.SVTTuple : Ast.SVTTensor; + const allVars = type.typeArgs.filter((arg) => { + return arg.kind === "TypeParam"; + }); + if (type.typeArgs.length === allVars.length) { + const argNames = new Set(allVars.map((v) => v.name.text)); + if (argNames.size !== allVars.length) { + // type variables are not distinct + yield EBadMethodType(type.loc); + return undefined; + } + return mvCons(allVars, type.loc); + } + const ground = yield* toGroundType(type, scopeRef); + if (!ground) { + yield EBadMethodType(type.loc); + return undefined; + } + return ground; + } + case "basic": { + return Ast.SGTBasic(type.type, type.loc); + } + } +} + +function* toGroundType( + type: Ast.CType, + scopeRef: () => Ast.CSource, +): Ast.Log { + switch (type.kind) { + case "recover": { + return undefined; + } + case "type_ref": { + const typeDecl = scopeRef().typeDecls.get(type.name.text); + if (!typeDecl) { + return throwInternal("Decoder returned broken reference"); + } + switch (typeDecl.decl.kind) { + case "contract": + case "trait": { + yield ENoMethods("contract", type.loc); + return undefined; + } + case "alias": { + return throwInternal("Decoder returned broken reference"); + } + case "struct": + case "message": + case "union": { + const ground: Ast.SelfTypeGround[] = []; + for (const arg of type.typeArgs) { + const result = yield* toGroundType(arg, scopeRef); + if (!result) { + return undefined; + } + ground.push(result); + } + return Ast.SGTRef( + type.name, + typeDecl.decl, + ground, + type.loc, + ); + } + } + // somehow typescript wants this + return throwInternal("Unknown declaration type"); + } + case "TypeAlias": { + return throwInternal("resolveAliases didn't resolve them"); + } + case "TypeParam": { + return undefined; + } + case "map_type": { + const key = yield* toGroundType(type.key, scopeRef); + const value = yield* toGroundType(type.value, scopeRef); + return key && value && Ast.SGTMap(key, value, type.loc); + } + case "TypeBounced": { + return undefined; + } + case "TypeMaybe": { + const child = yield* toGroundType(type.type, scopeRef); + return child && Ast.SGTMaybe(child, type.loc); + } + case "tuple_type": { + const children = yield* Ast.mapLog( + type.typeArgs, + function* (child) { + const result = yield* toGroundType(child, scopeRef); + return result ? [result] : []; + }, + ); + return Ast.SGTTuple(children.flat(), type.loc); + } + case "tensor_type": { + const children = yield* Ast.mapLog( + type.typeArgs, + function* (child) { + const result = yield* toGroundType(child, scopeRef); + return result ? [result] : []; + }, + ); + return Ast.SGTTensor(children.flat(), type.loc); + } + case "basic": { + return Ast.SGTBasic(type.type, type.loc); + } + } +} + +const EBadMethodType = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText( + `Type of self must either have no type parameters, or be a generic type with distinct type parameters`, + ), +); +const ENoMethods = (kind: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Cannot define methods on ${kind}`), +); diff --git a/src/next/types/fields.ts b/src/next/types/fields.ts new file mode 100644 index 0000000000..046d23e07f --- /dev/null +++ b/src/next/types/fields.ts @@ -0,0 +1,214 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { throwInternal } from "@/error/errors"; +import { decodeTypeLazy } from "@/next/types/type"; +import { checkFieldOverride } from "@/next/types/override"; +import { decodeConstantDef } from "@/next/types/constant-def"; +import { emptyTypeParams } from "@/next/types/type-params"; +import { decodeInitializerLazy } from "@/next/types/struct-fields"; + +type MaybeExpr = Ast.Thunk | undefined; + +export function* getFieldishGeneral( + Lazy: Ast.ThunkBuilder, + traitSigRef: Ast.CTrait | Ast.CContract, + typeName: Ast.TypeId, + traits: readonly Ast.Decl[], + constants: readonly Ast.FieldConstant[], + fields: readonly Ast.FieldDecl[], + scopeRef: () => Ast.CSource, +): Ast.Log>>> { + // collect all inherited fields and constants + const inherited: Map< + string, + Ast.DeclMem> + > = new Map(); + for (const { + via, + decl: { fieldish }, + } of traits) { + for (const name of fieldish.order) { + const field = fieldish.map.get(name); + if (!field) { + return throwInternal("Field was lost"); + } + const nextVia = Ast.ViaMemberTrait(name, via.defLoc, field.via); + const prev = inherited.get(name); + if (prev) { + yield Ast.ERedefineMember(name, prev.via, nextVia); + } else { + inherited.set(name, Ast.DeclMem(field.decl, nextVia)); + } + } + } + + const selfType = Ast.SVTRef(typeName, traitSigRef, [], typeName.loc); + + // in which order fields were defined + const order: string[] = []; + + // collection of all defined fields and constants + const all: Map>> = new Map(); + + // whether inherited field/constant was defined locally + const overridden: Set = new Set(); + + for (const field of fields) { + const name = field.name; + const nextVia = Ast.ViaMemberOrigin(typeName.text, field.loc); + + const prev = all.get(name.text); + if (prev) { + // duplicate local field + yield Ast.ERedefineMember(name.text, prev.via, nextVia); + } + + // remember order of fields + order.push(name.text); + + // decode field + all.set( + name.text, + decodeField(Lazy, typeName.text, field, scopeRef, selfType), + ); + + // check if this field was inherited + const prevInh = inherited.get(name.text); + if (prevInh) { + // remember that this inherited field was handled + overridden.add(name.text); + + if (prevInh.decl.kind !== "field") { + // cannot override constant with field + yield Ast.ERedefineMember(name.text, prevInh.via, nextVia); + } + } + } + + for (const field of constants) { + const { override, overridable, body } = field; + const { init, name, loc } = body; + const nextVia = Ast.ViaMemberOrigin(typeName.text, loc); + + const prev = all.get(name.text); + if (prev) { + // duplicate local constant + yield Ast.ERedefineMember(name.text, prev.via, nextVia); + } + + // we mostly need this for technical reasons: + // fields and constants occupy the same namespace + order.push(name.text); + + // remember that this inherited constant was handled. + // we always override previous constants for type + // recovery reasons, so no other conditions are given + const prevInh = inherited.get(name.text); + if (prevInh) { + overridden.add(name.text); + } + + // get the definition + const next = yield* decodeConstant( + Lazy, + init, + overridable, + nextVia, + scopeRef, + selfType, + ); + + // check that override/abstract/virtual modifiers are correct + yield* checkFieldOverride( + name.text, + prevInh, + next.decl.type, + nextVia, + override, + ); + + // we're all set to store this constant + all.set(name.text, next); + } + + // add fields/constants that were NOT overridden + for (const [name, field] of inherited) { + if (overridden.has(name)) { + continue; + } + if (field.decl.kind === "field") { + // fields must always be redefined + yield EMustCopyField(name, field.via); + } else { + // constants are inherited as is + } + all.set(name, field); + } + + return { + order, + map: all, + }; +} + +function decodeField( + Lazy: Ast.ThunkBuilder, + typeName: string, + field: Ast.FieldDecl, + scopeRef: () => Ast.CSource, + selfType: Ast.SelfType, +) { + const { initializer, type, loc } = field; + const nextVia = Ast.ViaMemberOrigin(typeName, loc); + + const decoded = decodeTypeLazy(Lazy, emptyTypeParams, type, scopeRef); + + const init = decodeInitializerLazy( + Lazy, + field.loc, + emptyTypeParams, + decoded, + initializer, + selfType, + scopeRef, + ); + + // decode field + return Ast.DeclMem(Ast.CField(decoded, init), nextVia); +} + +const EMustCopyField = (name: string, prev: Ast.ViaMember) => Ast.TcError( + prev.defLoc, + Ast.TEText( + `Field "${name}" was defined in parent trait, but never mentioned`, + ), + Ast.TEViaMember(prev), +); + +function* decodeConstant( + Lazy: Ast.ThunkBuilder, + init: Ast.ConstantInit, + overridable: boolean, + nextVia: Ast.ViaMember, + scopeRef: () => Ast.CSource, + selfType: Ast.SelfType, +): Ast.Log>> { + if (init.kind === "constant_decl") { + const type = decodeTypeLazy(Lazy, emptyTypeParams, init.type, scopeRef); + return Ast.DeclMem( + Ast.CFieldConstant(overridable, type, undefined), + nextVia, + ); + } else { + const [type, expr] = decodeConstantDef( + Lazy, + nextVia.defLoc, + emptyTypeParams, + init, + scopeRef, + selfType, + ); + return Ast.DeclMem(Ast.CFieldConstant(overridable, type, expr), nextVia); + } +} diff --git a/src/next/types/functions.ts b/src/next/types/functions.ts new file mode 100644 index 0000000000..6cf4827053 --- /dev/null +++ b/src/next/types/functions.ts @@ -0,0 +1,72 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import type { TactSource } from "@/next/imports/source"; +import { builtinFunctions } from "@/next/types/builtins"; +import { decodeFnType } from "@/next/types/type-fn"; +import { decodeBody } from "@/next/types/body"; + +const errorKind = "function"; + +export function* decodeFunctions( + Lazy: Ast.ThunkBuilder, + imported: readonly Ast.SourceCheckResult[], + source: TactSource, + scopeRef: () => Ast.CSource, +): Ast.Log>> { + const allFnSigs = [ + // imported + ...imported.flatMap(({ globals, importedBy }) => + [...globals.functions].map( + ([name, fn]) => + [ + name, + Ast.Decl(fn.decl, Ast.ViaImport(importedBy, fn.via)), + ] as const, + ), + ), + // local + ...(yield* Ast.mapLog(source.items.functions, function* (fn) { + return [ + fn.name.text, + Ast.Decl( + yield* decodeFunction(Lazy, fn, scopeRef), + Ast.ViaOrigin(fn.loc, source), + ), + ] as const; + })), + ]; + + // remove duplicates and builtins + const filteredSigs: Map> = new Map(); + for (const [name, sig] of allFnSigs) { + const isBuiltin = builtinFunctions.has(name); + if (isBuiltin) { + yield Ast.ERedefine(errorKind, name, Ast.ViaBuiltin(), sig.via); + continue; + } + const prev = filteredSigs.get(name); + if (!prev) { + filteredSigs.set(name, sig); + continue; + } + if (prev.via.source !== sig.via.source) { + yield Ast.ERedefine(errorKind, name, sig.via, prev.via); + } + } + return filteredSigs; +} + +function* decodeFunction( + Lazy: Ast.ThunkBuilder, + fn: Ast.Function, + scopeRef: () => Ast.CSource, +) { + const { type, inline, body, loc } = fn; + const fnType = yield* decodeFnType(Lazy, type, scopeRef); + return Ast.CFunction( + fnType, + inline, + yield* decodeBody(Lazy, body, fnType, loc, scopeRef), + ); +} diff --git a/src/next/types/lower.ts b/src/next/types/lower.ts new file mode 100644 index 0000000000..88357adb3d --- /dev/null +++ b/src/next/types/lower.ts @@ -0,0 +1,1131 @@ +/* eslint-disable require-yield */ +import { throwInternal } from "@/error/errors"; +import * as Ast from "@/next/ast"; + +type Lower = (t: T) => Ast.Log + +export const lowerSource: Lower = +function* (node) { + const typeDecls = yield* lowerTypeDecls(node.typeDecls); + const functions = yield* lowerFunctions(node.functions); + const constants = yield* lowerConstants(node.constants); + const extensions = yield* lowerExtensions(node.extensions); + return typeDecls && functions && constants && extensions && + Ast.LSource(typeDecls, functions, constants, extensions); +} + +const lowerTypeDecls: Lower< + ReadonlyMap>, + ReadonlyMap +> = function* (decls) { + let failed = false; + const result: Map = new Map(); + for (const [name, decl] of [...decls]) { + const res = yield* lowerTypeDecl(decl.decl); + if (res) { + result.set(name, res); + } else { + failed = true; + } + } + return failed ? undefined : result; +} + +const lowerTypeDecl: Lower = +function (node) { + switch (node.kind) { + case "alias": return lowerAlias(node); + case "contract": return lowerContract(node); + case "trait": return lowerTrait(node); + case "struct": return lowerStruct(node); + case "message": return lowerMessage(node); + case "union": return lowerUnion(node); + } +} + +const lowerAlias: Lower = +function* (node) { + const type = yield* lowerType(yield* node.type()); + return type && Ast.LAlias(node.typeParams, type); +} + +const lowerContract: Lower = +function* (node) { + const init = yield* lowerInit(node.init); + const members = yield* lowerContractMembers(node.content); + return init && members && Ast.LContract(node.attributes, init, members); +} + +const lowerInit: Lower = function (node) { + switch (node.kind) { + case "function": return lowerInitFunction(node); + case "empty": return lowerInitEmpty(node); + case "simple": return lowerInitSimple(node); + } +} + +const lowerInitFunction: Lower = +function* (node) { + const params = yield* lowerParameters(node.params); + const stmts = yield* lowerStatements(node.statements); + return params && stmts && Ast.LInitFn(params, stmts); +} + +const lowerInitEmpty: Lower = +function* (node) { + const old = yield* node.fill(); + if (!old) { + return undefined; + } + let failed = false; + const map: Map = new Map(); + for (const [name, param] of old.map) { + const res = yield* param(); + if (res) { + map.set(name, res); + } else { + failed = true; + } + } + return failed ? undefined : Ast.LInitEmpty(Ast.Ordered(old.order, map)); +} + +const lowerInitSimple: Lower = +function* (node) { + const map: Map = new Map(); + let failed = false; + for (const [name, field] of node.fill.map) { + const type = yield* lowerType(yield* field.type()); + if (!type) { + failed = true; + } + if (field.init) { + const init = yield* field.init(); + if (!init) { + failed = true; + } + if (init && type) { + map.set(name, Ast.LInitParam(type, init, field.loc)); + } + } else if (type) { + map.set(name, Ast.LInitParam(type, undefined, field.loc)); + } + } + return failed + ? undefined + : Ast.LInitSimple(Ast.Ordered(node.fill.order, map), node.loc); +} + +const lowerContractMembers: Lower< + Ast.Thunk, + Ast.LContractMembers +> = function* (thunk) { + const members = yield* thunk(); + const fieldish = yield* lowerFieldish(members.fieldish); + const methods = yield* lowerMethods(members.methods); + const receivers = yield* lowerReceivers(members.receivers); + return fieldish && methods && receivers && { fieldish, methods, receivers }; +} + +const lowerFieldish: Lower< + Ast.Ordered>>>>, + Ast.Ordered> +> = +function* (node) { + let failed = false; + const map: Map> = new Map(); + for (const [name, { decl }] of node.map) { + switch (decl.kind) { + case "field": { + const field = yield* lowerField(decl); + if (field) { + map.set(name, field); + } else { + failed = true; + } + continue; + } + case "constant": { + const constant = yield* lowerConstant(decl); + if (constant) { + map.set(name, constant); + } else { + failed = true; + } + continue; + } + } + } + return failed ? undefined : Ast.Ordered(node.order, map); +} + +const lowerField: Lower = +function* (node) { + const type = yield* lowerType(yield* node.type()); + if (node.init) { + const init = yield* node.init(); + if (!init) { + return undefined; + } + return type && Ast.LField(type, init); + } else { + return type && Ast.LField(type, undefined); + } +} + +const lowerConstant: Lower< + Ast.CFieldConstant>>, + Ast.LFieldConstant +> = function* (node) { + const init = yield* node.init(); + const type = yield* lowerType(yield* node.type()); + return type && init && Ast.LFieldConstant(type, init); +}; + +const lowerMethods: Lower< + ReadonlyMap>>, + ReadonlyMap> +> = function* (node) { + let failed = false; + const map: Map> = new Map(); + for (const [name, { decl }] of node) { + const type = yield* lowerMethodType(decl.type); + const body = yield* lowerBody(decl.body); + const getMethodId = decl.getMethodId && (yield* decl.getMethodId()); + if (type && body && (!decl.getMethodId || getMethodId)) { + map.set(name, Ast.LMethod( + type, + decl.inline, + body, + getMethodId, + )); + } else { + failed = true; + } + } + return failed ? undefined : map; +} + +const lowerMethodType: Lower = +function* (node) { + const params = yield* lowerParameters(node.params); + const returnType = yield* lowerType(yield* node.returnType()); + return params && returnType && Ast.LTMethod( + node.mutates, + node.typeParams, + node.self, + params, + returnType, + ); +}; + +const lowerBody: Lower = +function (node) { + switch (node.kind) { + case "tact": return lowerBodyTact(node); + case "func": return lowerBodyFunc(node); + case "fift": return lowerBodyFift(node); + } +}; + +const lowerBodyTact: Lower = +function* (node) { + const stmts = yield* lowerStatements(node.statements); + return stmts && Ast.LTactBody(stmts); +} +const lowerBodyFunc: Lower = +function* (node) { + return Ast.LFuncBody(node.nativeName); +} +const lowerBodyFift: Lower = +function* (node) { + const shuffle = yield* node.shuffle(); + return shuffle && Ast.LFiftBody(shuffle, node.instructions); +} + +const lowerReceivers: Lower = +function* (node) { + const bounce = yield* lowerBounce(node.bounce); + const internal = yield* lowerReceiver(node.internal); + const external = yield* lowerReceiver(node.external); + return bounce && internal && external && Ast.LReceivers(bounce, internal, external); +} + +const lowerBounce: Lower = +function* (node) { + const message = yield* mapRecv(lowerRecvMessage)(node.message); + const messageAny = node.messageAny + ? (yield* lowerRecvAny(node.messageAny.decl)) + : undefined; + return typeof message === 'undefined' + ? undefined + : (!node.messageAny || messageAny) && + Ast.LBounce(message, messageAny); +} + +const mapRecv = ( + cb: Lower +): Lower< + readonly Ast.DeclMem[], + readonly U[] +> => +function* (nodes) { + let failed = false; + const message: U[] = []; + for (const { decl } of nodes) { + const res = yield* cb(decl); + if (res) { + message.push(res); + } else { + failed = true; + } + } + return failed ? undefined : message; +}; + +const lowerRecvMessage: Lower< + Ast.CReceiverMessage, + Ast.LReceiverMessage +> = function* (node) { + const statements = yield* lowerStatements(node.statements); + const type = yield* lowerTypeRefOrBounced(node.type); + return statements && type && Ast.LReceiverMessage( + node.name, + type, + statements, + ) +}; + +const lowerTypeRefOrBounced: Lower< + Ast.CTRef | Ast.CTBounced, + Ast.LTRef | Ast.LTBounced +> = function (node) { + switch (node.kind) { + case "type_ref": return lowerTypeRef(node); + case "TypeBounced": return lowerTypeBounced(node); + } +}; + +const lowerReceiver: Lower< + Ast.CReceiver, + Ast.LReceiver +> = function* (node) { + const message = yield* mapRecv(lowerRecvOpcode)(node.message); + const messageAny = node.messageAny + ? (yield* lowerRecvAny(node.messageAny.decl)) + : undefined; + const stringAny = node.stringAny + ? (yield* lowerRecvAny(node.stringAny.decl)) + : undefined; + const empty = node.empty + ? (yield* lowerRecvEmpty(node.empty.decl)) + : undefined; + return typeof message === 'undefined' + ? undefined + : (!node.messageAny || messageAny) && + (!node.stringAny || stringAny) && + Ast.LReceiver(message, messageAny, stringAny, empty); +}; + +const lowerRecvAny: Lower = +function* (node) { + const statements = yield* lowerStatements(node.statements); + if (!statements) { + return undefined; + } + return Ast.LReceiverAny(node.name, statements); +} +const lowerRecvEmpty: Lower = +function* (node) { + const statements = yield* lowerStatements(node.statements); + if (!statements) { + return undefined; + } + return Ast.LReceiverEmpty(statements); +} + +const lowerRecvOpcode: Lower< + Ast.CReceiverOpcode, + Ast.LReceiverOpcode +> = function* (node) { + switch (node.kind) { + case "string": { + const statements = yield* lowerStatements(node.statements); + return statements && Ast.LReceiverString(node.comment, statements); + } + case "binary": { + const type = yield* lowerTypeRefOrBounced(node.type); + const statements = yield* lowerStatements(node.statements); + return type && statements && Ast.LReceiverMessage(node.name, type, statements); + } + } +}; + +const lowerTrait: Lower = +function* (node) { + const content = yield* node.content(); + const fieldish = yield* lowerFieldishTrait(content.fieldish); + const methods = yield* lowerMethodsTrait(content.methods); + const receivers = yield* lowerReceivers(content.receivers); + return fieldish && methods && receivers && Ast.LTrait({ fieldish, methods, receivers }); +} + +const lowerMethodsTrait: Lower< + ReadonlyMap>>, + ReadonlyMap> +> = function* (node) { + let failed = false; + const map: Map> = new Map(); + for (const [name, { decl }] of node) { + const type = yield* lowerMethodType(decl.type); + const body = decl.body ? (yield* lowerBody(decl.body)) : undefined; + const getMethodId = decl.getMethodId && (yield* decl.getMethodId()); + if (type && (!decl.body || body) && (!decl.getMethodId || getMethodId)) { + map.set(name, Ast.LMethod( + type, + decl.inline, + body, + getMethodId, + )); + } else { + failed = true; + } + } + return failed ? undefined : map; +} + +const lowerFieldishTrait: Lower< + Ast.Ordered>>>>, + Ast.Ordered> +> = +function* (node) { + let failed = false; + const map: Map> = new Map(); + for (const [name, { decl }] of node.map) { + switch (decl.kind) { + case "field": { + const field = yield* lowerField(decl); + if (field) { + map.set(name, field); + } else { + failed = true; + } + continue; + } + case "constant": { + const constant = yield* lowerConstantTrait(decl); + if (constant) { + map.set(name, constant); + } else { + failed = true; + } + continue; + } + } + } + return failed ? undefined : Ast.Ordered(node.order, map); +} + +const lowerConstantTrait: Lower< + Ast.CFieldConstant> | undefined>, + Ast.LFieldConstant +> = function* (node) { + const init = node.init ? (yield* node.init()) : undefined; + const type = yield* lowerType(yield* node.type()); + return type && (!node.init || init) && Ast.LFieldConstant(type, init); +}; + +const lowerStruct: Lower = +function* (node) { + const fields = yield* lowerFields(node.fields); + return fields && Ast.LStruct(node.typeParams, fields); +} + +const lowerFields: Lower, Ast.Ordered> = +function* (node) { + let failed = false; + const map: Map = new Map(); + for (const [name, field] of node.map) { + const type = yield* lowerType(yield* field.type()); + const init = field.init ? (yield* field.init()) : undefined; + if (type && (!field.init || init)) { + map.set(name, Ast.LField(type, init)); + } else { + failed = true; + } + } + return failed ? undefined : Ast.Ordered(node.order, map); +} + +const lowerMessage: Lower = +function* (node) { + const opcode = yield* node.opcode(); + const fields = yield* lowerFields(node.fields); + return typeof opcode === 'undefined' + ? undefined + : fields && Ast.LMessage(opcode, fields); +} + +const lowerUnion: Lower = +function* (node) { + let failed = false; + const cases: Map> = new Map(); + for (const [caseName, rawFields] of node.cases) { + const fields: Map = new Map(); + for (const [fieldName, field] of rawFields) { + const type = yield* lowerType(yield* field.type()); + const init = field.init ? (yield* field.init()) : undefined; + if (type && (!field.init || init)) { + fields.set(fieldName, Ast.LField(type, init)); + } else { + failed = true; + } + } + cases.set(caseName, fields); + } + return failed ? undefined : Ast.LUnion(node.typeParams, cases); +} + +const lowerFunctions: Lower< + ReadonlyMap>, + ReadonlyMap +> = function* (decls) { + let failed = false; + const result: Map = new Map(); + for (const [name, { decl }] of decls) { + const type = yield* lowerFunctionType(decl.type); + const body = yield* lowerBody(decl.body); + if (type && body) { + result.set(name, Ast.LFunction(type, decl.inline, body)); + } else { + failed = true; + } + } + return failed ? undefined : result; +} + +const lowerFunctionType: Lower = function* (node) { + const params = yield* lowerParameters(node.params); + const returnType = yield* lowerType(yield* node.returnType()); + return params && returnType && Ast.LTFunction(node.typeParams, params, returnType); +} + +const lowerConstants: Lower< + ReadonlyMap>, + ReadonlyMap +> = function* (decls) { + let failed = false; + const result: Map = new Map(); + for (const [name, { decl }] of decls) { + const type = yield* lowerType(yield* decl.type()); + const initializer = yield* decl.initializer(); + if (type && initializer) { + result.set(name, Ast.LConstant(initializer, type)); + } else { + failed = true; + } + } + return failed ? undefined : result; +} + +const lowerExtensions: Lower< + ReadonlyMap[]>>, + ReadonlyMap +> = function* (decls) { + let failed = false; + const result: Map = new Map(); + for (const [name, thunk] of decls) { + const extensions = yield* thunk(); + const exts: Ast.LExtension[] = []; + for (const { decl: extension } of extensions) { + const type = yield* lowerMethodType(extension.type); + const body = yield* lowerBody(extension.body); + if (type && body) { + exts.push(Ast.LExtension(type, extension.inline, body)); + } else { + failed = true; + } + } + result.set(name, exts); + } + return failed ? undefined : result; +} + +const lowerStatements: Lower = +function* (node) { + const stmts = yield* node(); + if (!stmts) { + return undefined; + } + const body = yield* lowerStatementList(stmts.body); + return typeof body === 'undefined' + ? undefined + : Ast.LStatements(body, stmts.effects); +} + +const lowerStatementList: Lower = +function* (stmts) { + let failed = false; + const result: Ast.LStmt[] = []; + for (const stmt of stmts) { + const lowered = yield* lowerStatement(stmt); + if (lowered) { + result.push(lowered); + } else { + failed = true; + } + } + return failed ? undefined : result; +} + +const lowerStatement: Lower = +function (node) { + switch (node.kind) { + case "statement_let": return lowerStatementLet(node); + case "statement_return": return lowerStatementReturn(node); + case "statement_expression": return lowerStatementExpression(node); + case "statement_assign": return lowerStatementAssign(node); + case "statement_augmentedassign": return lowerStatementAugmentedAssign(node); + case "statement_condition": return lowerStatementCondition(node); + case "statement_while": return lowerStatementWhile(node); + case "statement_until": return lowerStatementUntil(node); + case "statement_repeat": return lowerStatementRepeat(node); + case "statement_try": return lowerStatementTry(node); + case "statement_foreach": return lowerStatementForEach(node); + case "statement_destruct": return lowerStatementDestruct(node); + case "statement_block": return lowerStatementBlock(node); + } +} + +const lowerStatementLet: Lower = +function* (node) { + const expr = yield* lowerExpr(node.expression); + return expr && Ast.LStmtLet(node.name, expr, node.loc); +} + +const lowerStatementReturn: Lower = +function* (node) { + const expr = node.expression ? (yield* lowerExpr(node.expression)) : undefined; + return (!node.expression || expr) && Ast.LStmtReturn(expr, node.loc); +} + +const lowerStatementExpression: Lower = +function* (node) { + const expr = yield* lowerExpr(node.expression); + return expr && Ast.LStmtExpression(expr, node.loc); +} + +const lowerStatementAssign: Lower = +function* (node) { + const path = yield* lowerLValue(node.path); + const expr = yield* lowerExpr(node.expression); + return path && expr && Ast.LStmtAssign(path, expr, node.loc); +} + +const lowerStatementAugmentedAssign: Lower = +function* (node) { + const path = yield* lowerLValue(node.path); + const expr = yield* lowerExpr(node.expression); + return path && expr && Ast.LStmtAugmentedAssign(node.op, path, expr, node.loc); +} + +const lowerStatementCondition: Lower = +function* (node) { + const condition = yield* lowerExpr(node.condition); + const thenBranch = yield* lowerStatementList(node.trueStatements); + const elseBranch = node.falseStatements + ? (yield* lowerStatementList(node.falseStatements)) + : undefined; + return condition && thenBranch && (!node.falseStatements || elseBranch) && + Ast.LStmtCondition(condition, thenBranch, elseBranch, node.loc); +} + +const lowerStatementWhile: Lower = +function* (node) { + const condition = yield* lowerExpr(node.condition); + const body = yield* lowerStatementList(node.statements); + return condition && body && Ast.LStmtWhile(condition, body, node.loc); +} + +const lowerStatementUntil: Lower = +function* (node) { + const condition = yield* lowerExpr(node.condition); + const body = yield* lowerStatementList(node.statements); + return condition && body && Ast.LStmtUntil(condition, body, node.loc); +} + +const lowerStatementRepeat: Lower = +function* (node) { + const body = yield* lowerStatementList(node.statements); + const iterations = yield* lowerExpr(node.iterations); + return body && iterations && Ast.LStmtRepeat(iterations, body, node.loc); +} + +const lowerStatementTry: Lower = +function* (node) { + const body = yield* lowerStatementList(node.statements); + const catchBlock = node.catchBlock + ? (yield* lowerCatchBlock(node.catchBlock)) + : undefined; + return body && (!node.catchBlock || catchBlock) && + Ast.LStmtTry(body, catchBlock, node.loc); +} + +const lowerCatchBlock: Lower = +function* (node) { + const body = yield* lowerStatementList(node.statements); + return body && Ast.LCatchBlock(node.name, body); +} + +const lowerStatementForEach: Lower = +function* (node) { + const expr = yield* lowerExpr(node.map); + const body = yield* lowerStatementList(node.statements); + return expr && body && Ast.LStmtForEach(node.keyName, node.valueName, expr, body, node.loc); +} + +const lowerStatementDestruct: Lower = +function* (node) { + const expr = yield* lowerExpr(node.expression); + const patterns = yield* lowerDestructPatterns(node.identifiers); + return expr && patterns && Ast.LStmtDestruct( + node.type, + patterns, + node.ignoreUnspecifiedFields, + expr, + node.loc, + ); +} + +const lowerDestructPatterns: Lower< + Ast.Ordered, + Ast.Ordered +> = function* (patterns) { + return patterns; +} + +const lowerStatementBlock: Lower = +function* (node) { + const body = yield* lowerStatementList(node.statements); + return body && Ast.LStmtBlock(body, node.loc); +} + +const lowerParameters: Lower = +function* (node) { + const order = yield* Ast.mapLog(node.order, param => lowerParameter(param)); + const filtered: Ast.LParameter[] = []; + let failed = false; + for (const param of order) { + if (param) { + filtered.push(param); + } else { + failed = true; + } + } + return failed + ? undefined + : order && Ast.LParameters(filtered, node.set); +} + +const lowerLValue: Lower = +function (node) { + switch (node.kind) { + case "var": return lowerLVar(node); + case "self": return lowerLSelf(node); + case "field_access": return lowerLFieldAccess(node); + } +} + +const lowerLVar: Lower = +function* (node) { + const type = yield* lowerType(node.computedType); + return type && Ast.LLVar(node.name, type, node.loc); +} + +const lowerLSelf: Lower = +function* (node) { + return Ast.LLSelf(node.computedType, node.loc); +} + +const lowerLFieldAccess: Lower = +function* (node) { + const aggregate = yield* lowerLValue(node.aggregate); + const type = yield* lowerType(node.computedType); + return aggregate && type && + Ast.LLFieldAccess(aggregate, node.field, type, node.loc); +} + +const lowerExpr: Lower = +function (node) { + switch (node.kind) { + case "string": return lowerString(node); + case "number": return lowerNumber(node); + case "boolean": return lowerBoolean(node); + case "op_binary": return lowerOpBinary(node); + case "op_unary": return lowerOpUnary(node); + case "conditional": return lowerConditional(node); + case "method_call": return lowerMethodCall(node); + case "static_call": return lowerStaticCall(node); + case "static_method_call": return lowerStaticMethodCall(node); + case "field_access": return lowerFieldAccess(node); + case "struct_instance": return lowerStructInstance(node); + case "init_of": return lowerInitOf(node); + case "code_of": return lowerCodeOf(node); + case "null": return lowerNull(node); + case "var": return lowerVar(node); + case "self": return lowerSelf(node); + case "unit": return lowerUnit(node); + case "tuple": return lowerTuple(node); + case "tensor": return lowerTensor(node); + case "map_literal": return lowerMapLiteral(node); + case "set_literal": return lowerSetLiteral(node); + } +} + +const lowerTypeArgs: Lower = +function* (args) { + let failed = false; + const map: Map = new Map(); + for (const [name, type] of args) { + const res = yield* lowerType(type); + if (res) { + map.set(name, res); + } else { + failed = true; + } + } + return failed ? undefined : map; +}; + +const lowerExprs: Lower = +function* (nodes) { + let failed = false; + const result: Ast.LExpr[] = []; + for (const node of nodes) { + const res = yield* lowerExpr(node); + if (res) { + result.push(res); + } else { + failed = true; + } + } + return failed ? undefined : result; +}; + +const lowerString: Lower = +function* (node) { + const type = yield* lowerTypeBasic(node.computedType); + return type && Ast.LString(node.value, type, node.loc); +} +const lowerNumber: Lower = +function* (node) { + const type = yield* lowerTypeBasic(node.computedType); + return type && Ast.LNumber(node.base, node.value, type, node.loc); +} +const lowerBoolean: Lower = +function* (node) { + const type = yield* lowerTypeBasic(node.computedType); + return type && Ast.LBoolean(node.value, type, node.loc); +} +const lowerOpBinary: Lower = +function* (node) { + const left = yield* lowerExpr(node.left); + const right = yield* lowerExpr(node.right); + const typeArgs = yield* lowerTypeArgs(node.typeArgs); + const type = yield* lowerType(node.computedType); + return left && right && type && typeArgs && + Ast.LOpBinary( + node.op, + left, + right, + typeArgs, + type, + node.loc, + ); +} +const lowerOpUnary: Lower = +function* (node) { + const operand = yield* lowerExpr(node.operand); + const typeArgs = yield* lowerTypeArgs(node.typeArgs); + const type = yield* lowerType(node.computedType); + return operand && type && typeArgs && + Ast.LOpUnary( + node.op, + operand, + typeArgs, + type, + node.loc, + ); +} +const lowerConditional: Lower = +function* (node) { + const condition = yield* lowerExpr(node.condition); + const thenBranch = yield* lowerExpr(node.thenBranch); + const elseBranch = yield* lowerExpr(node.elseBranch); + const type = yield* lowerType(node.computedType); + return condition && thenBranch && elseBranch && type && + Ast.LConditional(condition, thenBranch, elseBranch, type, node.loc); +} +const lowerMethodCall: Lower = +function* (node) { + const self = yield* lowerExpr(node.self); + const typeArgs = yield* lowerTypeArgs(node.typeArgs); + const args = yield* lowerExprs(node.args); + const computedType = yield* lowerType(node.computedType); + return self && typeArgs && args && computedType && + Ast.LMethodCall( + self, + node.method, + args, + typeArgs, + computedType, + node.loc, + ); +} +const lowerStaticCall: Lower = +function* (node) { + const typeArgs = yield* lowerTypeArgs(node.typeArgs); + const args = yield* lowerExprs(node.args); + const computedType = yield* lowerType(node.computedType); + return typeArgs && args && computedType && + Ast.LStaticCall( + node.function, + typeArgs, + args, + computedType, + node.loc, + ); +} +const lowerStaticMethodCall: Lower = +function* (node) { + const typeArgs = yield* lowerTypeArgs(node.typeArgs); + const args = yield* lowerExprs(node.args); + const computedType = yield* lowerType(node.computedType); + return typeArgs && args && computedType && + Ast.LStaticMethodCall( + node.self, + typeArgs, + node.function, + args, + computedType, + node.loc, + ); +} +const lowerFieldAccess: Lower = +function* (node) { + const aggregate = yield* lowerExpr(node.aggregate); + const type = yield* lowerType(node.computedType); + return aggregate && type && + Ast.LFieldAccess( + aggregate, + node.field, + type, + node.loc, + ); +} +const lowerStructInstance: Lower = +function* (node) { + if (node.computedType.kind === 'recover') { + return undefined; + } + const type = yield* lowerTypeRef(node.computedType); + const result: Map = new Map(); + let failed = false; + for (const name of node.fields.order) { + const field = node.fields.map.get(name); + if (!field) { + return throwInternal("Ordered<>: lost field"); + } + const res = yield* lowerExpr(field); + if (res) { + result.set(name, res); + } else { + failed = true; + } + } + return failed ? undefined : type && + Ast.LStructCons( + Ast.Ordered(node.fields.order, result), + type, + node.loc, + ); +} +const lowerInitOf: Lower = +function* (node) { + const type = yield* lowerType(node.computedType); + const args = yield* lowerExprs(node.args); + return type && args && + Ast.LInitOf( + node.contract, + args, + type, + node.loc, + ); +} +const lowerCodeOf: Lower = +function* (node) { + const type = yield* lowerType(node.computedType); + return type && + Ast.LCodeOf( + node.contract, + type, + node.loc, + ); +} +const lowerNull: Lower = +function* (node) { + const type = yield* lowerTypeBasic(node.computedType); + return type && Ast.LNull(type, node.loc); +} +const lowerVar: Lower = +function* (node) { + const type = yield* lowerType(node.computedType); + return type && Ast.LVar(node.name, type, node.loc); +} +const lowerSelf: Lower = +function* (node) { + return Ast.LSelf(node.computedType, node.loc); +} +const lowerUnit: Lower = +function* (node) { + const type = yield* lowerTypeBasic(node.computedType); + return type && Ast.LUnit(type, node.loc); +} +const lowerTuple: Lower = +function* (node) { + const type = yield* lowerTypeTuple(node.computedType); + const elements = yield* lowerExprs(node.children); + return type && elements && + Ast.LTuple( + elements, + type, + node.loc, + ); +} +const lowerTensor: Lower = +function* (node) { + const type = yield* lowerTypeTensor(node.computedType); + const elements = yield* lowerExprs(node.children); + return type && elements && + Ast.LTensor( + elements, + type, + node.loc, + ); +} +const lowerMapLiteral: Lower = +function* (node) { + const type = yield* lowerTypeMap(node.computedType); + let failed = false; + const fields: Ast.LMapField[] = []; + for (const field of node.fields) { + const key = yield* lowerExpr(field.key); + const value = yield* lowerExpr(field.value); + if (key && value) { + fields.push({ key, value }); + } else { + failed = true; + } + } + return failed ? undefined : type && + Ast.LMapLiteral( + fields, + type, + node.loc, + ); +} +const lowerSetLiteral: Lower = +function* (_node) { + return throwInternal("Set literals not supported"); +} + +const lowerParameter: Lower = +function* (node) { + const type = yield* lowerType(yield* node.type()); + return type && Ast.LParameter(node.name, type, node.loc); +} + +const lowerType: Lower = +function (node) { + switch (node.kind) { + case "recover": return lowerRecover(node); + case "type_ref": return lowerTypeRef(node); + case "TypeAlias": return lowerTypeAliasRef(node); + case "TypeParam": return lowerTypeParam(node); + case "map_type": return lowerTypeMap(node); + case "TypeBounced": return lowerTypeBounced(node); + case "TypeMaybe": return lowerTypeMaybe(node); + case "tuple_type": return lowerTypeTuple(node); + case "tensor_type": return lowerTypeTensor(node); + case "basic": return lowerTypeBasic(node); + } +} + +const lowerRecover: Lower = +function* () { + return undefined; +}; + +const lowerTypes: Lower = +function* (nodes) { + let failed = false; + const result: Ast.LType[] = []; + for (const node of nodes) { + const res = yield* lowerType(node); + if (res) { + result.push(res); + } else { + failed = true; + } + } + return failed ? undefined : result; +}; + +const lowerTypeRef: Lower = +function* (node) { + const args = yield* lowerTypes(node.typeArgs); + return args && Ast.LTRef(node.name, node.type, args, node.loc); +}; + +const lowerTypeAliasRef: Lower = +function* (node) { + if (node.type.kind === 'NotDealiased') { + return throwInternal("Non-dealiased type in lowering"); + } + const type = yield* lowerType(node.type); + const args = yield* lowerTypes(node.typeArgs); + return type && args && Ast.LTAliasRef(node.name, type, args, node.loc); +}; +const lowerTypeParam: Lower = +function* (node) { + return Ast.LTParamRef(node.name, node.loc); +}; +const lowerTypeMap: Lower = +function* (node) { + const key = yield* lowerType(node.key); + const value = yield* lowerType(node.value); + return key && value && Ast.LTMap(key, value, node.loc); +}; +const lowerTypeBounced: Lower = +function* (node) { + return Ast.LTBounced(node.name, node.loc); +}; +const lowerTypeMaybe: Lower = +function* (node) { + const type = yield* lowerType(node.type); + return type && Ast.LTMaybe(type, node.loc); +}; +const lowerTypeTuple: Lower = +function* (node) { + const args = yield* lowerTypes(node.typeArgs); + return args && Ast.LTTuple(args, node.loc); +}; +const lowerTypeTensor: Lower = +function* (node) { + const args = yield* lowerTypes(node.typeArgs); + return args && Ast.LTTensor(args, node.loc); +}; +const lowerTypeBasic: Lower = +function* (node) { + return Ast.LTBasic(node.type, node.loc); +}; diff --git a/src/next/types/lvalue.ts b/src/next/types/lvalue.ts new file mode 100644 index 0000000000..0685e37536 --- /dev/null +++ b/src/next/types/lvalue.ts @@ -0,0 +1,69 @@ +/* eslint-disable require-yield */ +import * as Ast from "@/next/ast"; + +export function* convertExprToLValue( + node: Ast.CExpr, +): Ast.Log { + const result = yield* convertExprToLValueAux(node); + if (result?.kind === 'self') { + yield ENoSelfAssign(node.loc); + return undefined; + } + return result; +} +const ENoSelfAssign = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Cannot assign to self`), +); + +function* convertExprToLValueAux( + node: Ast.CExpr, +): Ast.Log { + switch (node.kind) { + case "field_access": { + const aggregate = yield* convertExprToLValue(node.aggregate); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + return ( + aggregate && + Ast.CLFieldAccess( + aggregate, + node.field, + node.computedType, + node.loc, + ) + ); + } + case "var": + case "self": { + return node; + } + case "string": + case "number": + case "boolean": + case "op_binary": + case "op_unary": + case "conditional": + case "method_call": + case "static_call": + case "static_method_call": + case "struct_instance": + case "init_of": + case "code_of": + case "null": + case "unit": + case "tuple": + case "tensor": + case "map_literal": + case "set_literal": { + yield ENotLValue(node.loc); + return undefined; + } + } +} +const ENotLValue = (prev: Ast.Loc) => Ast.TcError( + prev, + Ast.TEText( + `This expression cannot be used on the left side of assignment`, + ), + Ast.TECode(prev), +); diff --git a/src/next/types/message.ts b/src/next/types/message.ts new file mode 100644 index 0000000000..f868269b69 --- /dev/null +++ b/src/next/types/message.ts @@ -0,0 +1,95 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { throwInternal } from "@/error/errors"; +import * as Ast from "@/next/ast"; +import { Int } from "@/next/types/builtins"; +import { evalExpr } from "@/next/types/expr-eval"; +import { decodeExpr } from "@/next/types/expression"; +import { decodeFields } from "@/next/types/struct-fields"; +import { assignType } from "@/next/types/type"; +import { emptyTypeParams } from "@/next/types/type-params"; +import { highest32ofSha256, sha256 } from "@/utils/sha256"; + +export function* decodeMessage( + Lazy: Ast.ThunkBuilder, + message: Ast.MessageDecl, + scopeRef: () => Ast.CSource, +): Ast.Log { + const fields = yield* decodeFields( + Lazy, + message.fields, + emptyTypeParams, + scopeRef, + ); + const lazyExpr = Lazy({ + callback: function* (Lazy) { + const opcode = yield* decodeOpcode( + Lazy, + emptyTypeParams, + message.opcode, + message.name.text, + fields.order, + scopeRef, + ); + if (opcode === 0n) { + yield EZero(message.loc); + } else if (opcode < 0n) { + yield ENegative(message.loc); + } else if (opcode > 0xffff_ffff) { + yield ETooLarge(message.loc); + } + return opcode; + }, + context: [Ast.TEText("computing opcode")], + loc: message.loc, + recover: undefined, + }); + + return Ast.CMessage(lazyExpr, fields); +} +const EZero = (next: Ast.Loc) => Ast.TcError( + next, + Ast.TEText(`Zero opcode is reserved for text comments`), +); +const ENegative = (next: Ast.Loc) => Ast.TcError( + next, + Ast.TEText(`Opcode must be positive`), +); +const ETooLarge = (next: Ast.Loc) => Ast.TcError( + next, + Ast.TEText(`Opcode is too large`), +); + +function* decodeOpcode( + Lazy: Ast.ThunkBuilder, + typeParams: Ast.CTypeParams, + opcode: Ast.Expression | undefined, + messageName: string, + fieldsNames: readonly string[], + scopeRef: () => Ast.CSource, +) { + if (opcode) { + const expr = yield* decodeExpr( + Lazy, + typeParams, + opcode, + scopeRef, + undefined, + new Map(), + ); + const computed = expr.value.computedType; + if ( + yield* assignType(opcode.loc, emptyTypeParams, Int, computed, false) + ) { + const result = yield* evalExpr(expr.value, scopeRef); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (result.kind === "number") { + return result.value; + } else { + return throwInternal("Const eval returned non-number for Int"); + } + } + } + const signature = messageName + "{" + fieldsNames.join(",") + "}"; + return highest32ofSha256(sha256(signature)); +} diff --git a/src/next/types/methods.ts b/src/next/types/methods.ts new file mode 100644 index 0000000000..74e59ccb8b --- /dev/null +++ b/src/next/types/methods.ts @@ -0,0 +1,223 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { decodeBody } from "@/next/types/body"; +import { decodeFnType } from "@/next/types/type-fn"; +import { checkMethodOverride } from "@/next/types/override"; +import { decodeExpr } from "@/next/types/expression"; +import { crc16 } from "@/utils/crc16"; +import { Int, tactMethodIds } from "@/next/types/builtins"; +import { evalExpr } from "@/next/types/expr-eval"; +import { assignType } from "@/next/types/type"; +import { emptyTypeParams } from "@/next/types/type-params"; + +export function* getMethodsGeneral( + Lazy: Ast.ThunkBuilder, + declSig: Ast.CTrait | Ast.CContract, + typeName: Ast.TypeId, + traits: readonly Ast.Decl[], + methods: readonly Ast.Method[], + scopeRef: () => Ast.CSource, +): Ast.Log< + ReadonlyMap>> +> { + // collect all inherited methods + const inherited: Map< + string, + Ast.DeclMem> + > = new Map(); + for (const { + via, + decl: { methods }, + } of traits) { + for (const [name, method] of methods) { + const nextVia = Ast.ViaMemberTrait(name, via.defLoc, method.via); + const prev = inherited.get(name); + if (prev) { + yield Ast.ERedefineMember(name, prev.via, nextVia); + } else { + inherited.set(name, Ast.DeclMem(method.decl, nextVia)); + } + } + } + + // collection of all defined methods + const all: Map< + string, + Ast.DeclMem> + > = new Map(); + + // whether inherited field/constant was defined locally + const overridden: Set = new Set(); + + for (const method of methods) { + const { override, overridable, mutates, fun, get } = method; + const { name, inline, type, body, loc } = fun; + const nextVia = Ast.ViaMemberOrigin(typeName.text, loc); + + const decodedFn = yield* decodeFnType(Lazy, type, scopeRef); + const selfType = Ast.SVTRef(typeName, declSig, [], loc); + const methodType = Ast.CTMethod( + true, // always mutates + emptyTypeParams, + selfType, + decodedFn.params, + decodedFn.returnType, + ); + const decodedBody = + body.kind !== "abstract_body" + ? yield* decodeBody(Lazy, body, methodType, loc, scopeRef) + : undefined; + const getMethodId = decodeGetLazy( + Lazy, + emptyTypeParams, + name, + get, + scopeRef, + selfType, + ); + if (type.typeParams.length > 0) { + yield EGenericMethod(loc); + } + + const prevInh = inherited.get(name.text); + if (prevInh) { + overridden.add(name.text); + } + + // check that override/abstract/virtual modifiers are correct + yield* checkMethodOverride( + name.text, + prevInh, + methodType, + nextVia, + override, + ); + + const methodSig = Ast.CMethod( + overridable, + methodType, + inline, + decodedBody, + getMethodId, + ); + + all.set(name.text, Ast.DeclMem(methodSig, nextVia)); + } + + // add methods that were NOT overridden + for (const [name, field] of inherited) { + if (overridden.has(name)) { + continue; + } + all.set(name, field); + } + + return all; +} +const EGenericMethod = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Method cannot be generic`), +); + +function decodeGetLazy( + Lazy: Ast.ThunkBuilder, + typeParams: Ast.CTypeParams, + fnName: Ast.Id, + get: Ast.GetAttribute | undefined, + scopeRef: () => Ast.CSource, + selfType: Ast.SelfType, +): undefined | Ast.Thunk { + if (!get) { + return undefined; + } + return Lazy({ + callback: (Lazy) => + decodeGet(Lazy, typeParams, fnName, get, scopeRef, selfType), + context: [Ast.TEText("checking get() opcode")], + loc: get.loc, + recover: undefined, + }); +} + +function* decodeGet( + Lazy: Ast.ThunkBuilder, + typeParams: Ast.CTypeParams, + fnName: Ast.Id, + get: Ast.GetAttribute, + scopeRef: () => Ast.CSource, + selfType: Ast.SelfType, +): Ast.Log { + if (get.methodId) { + const expr = yield* decodeExpr( + Lazy, + typeParams, + get.methodId, + scopeRef, + selfType, + new Map(), + ); + const type = expr.value.computedType; + if (yield* assignType(expr.value.loc, emptyTypeParams, Int, type, false)) { + const methodId = yield* evalExpr(expr.value, scopeRef); + if ( + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + methodId.kind === "number" && + (yield* checkMethodId(methodId.value, expr.value.loc)) + ) { + return methodId.value; + } + // if evaluation failed, fallthrough to computing it + } + } + + // compute method id out of function name + const methodId = BigInt((crc16(fnName.text) & 0xffff) | 0x10000); + // just in case + yield* checkMethodId(methodId, fnName.loc); + return methodId; +} + +function* checkMethodId(methodId: bigint, loc: Ast.Loc) { + if (methodId < -(2n ** 18n) || methodId >= 2n ** 18n) { + // method ids are 19-bit signed integers + yield EBadId(loc); + return false; + } else if (-4n <= methodId && methodId < 2n ** 14n) { + // method ids -4, -3, -2, -1, 0 ... 2^14 - 1 (inclusive) are kind of reserved by TVM + // for the upper bound see F12_n (CALL) TVM instruction + // and many small ids will be taken by internal procedures + // + // also, some ids are taken by the getters generated by Tact: + // supported_interfaces -> 113617 + // lazy_deployment_completed -> 115390 + // get_abi_ipfs -> 121275 + yield EReservedTvmId(loc); + return false; + } else if (tactMethodIds.includes(methodId)) { + yield EReservedTactId(loc, tactMethodIds); + return false; + } else { + return true; + } +} + +const EBadId = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Method ids must fit 19-bit signed integer range`), +); +const EReservedTvmId = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText( + `Method ids cannot overlap with the TVM reserved ids: -4, -3, -2, -1, 0 ... 2^14 - 1`, + ), +); +const EReservedTactId = ( + loc: Ast.Loc, + tactMethodIds: readonly bigint[], +) => Ast.TcError( + loc, + Ast.TEText( + `Method ids cannot overlap with Tact reserved method ids: ${tactMethodIds.map((n) => n.toString()).join(", ")}`, + ), +); diff --git a/src/next/types/name.ts b/src/next/types/name.ts new file mode 100644 index 0000000000..bb7c1e7a24 --- /dev/null +++ b/src/next/types/name.ts @@ -0,0 +1,11 @@ +import { throwInternal } from "@/error/errors"; + +export const recoverName = (name: string, set: ReadonlySet) => { + for (let i = 0; i < 100; ++i) { + const nextName = `${name}${i}`; + if (!set.has(nextName)) { + return nextName; + } + } + return throwInternal("Iteration limit reached"); +}; diff --git a/src/next/types/override.ts b/src/next/types/override.ts new file mode 100644 index 0000000000..3cb0ce0d57 --- /dev/null +++ b/src/next/types/override.ts @@ -0,0 +1,111 @@ +import * as Ast from "@/next/ast"; +import { assignMethodType, assignType } from "@/next/types/type"; +import { emptyTypeParams } from "@/next/types/type-params"; + +export function* checkFieldOverride( + name: string, + prev: + | Ast.DeclMem< + Ast.CFieldish> | undefined> + > + | undefined, + nextType: Ast.Thunk, + nextVia: Ast.ViaMember, + override: boolean, +): Ast.Log { + if (prev) { + if (prev.decl.kind !== "constant") { + // cannot override field with constant + yield Ast.ERedefineMember(name, prev.via, nextVia); + } else if (override) { + // overriding without override + yield ENeedOverride(name, prev.via, nextVia); + } else if (!prev.decl.overridable) { + // to override it must be virtual or abstract + yield ENeedAbstract(name, prev.via, nextVia); + } else { + // overriding constant + yield* assignType( + nextVia.defLoc, + emptyTypeParams, + yield* prev.decl.type(), + yield* nextType(), + true, + ); + } + } else { + if (override) { + // override of nothing + yield EEmptyOverride(name, nextVia); + } else { + // defining new constant + } + } +} + +export function* checkMethodOverride( + name: string, + prev: Ast.DeclMem> | undefined, + nextType: Ast.CTMethod, + nextVia: Ast.ViaMember, + override: boolean, +): Ast.Log { + if (prev) { + if (override) { + // overriding without override + yield ENeedOverride(name, prev.via, nextVia); + } else if (!prev.decl.overridable) { + // to override it must be virtual or abstract + yield ENeedAbstract(name, prev.via, nextVia); + } else { + // overriding method + yield* assignMethodType( + prev.decl.type, + nextType, + prev.via, + nextVia, + ); + } + } else { + if (override) { + // override of nothing + yield EEmptyOverride(name, nextVia); + } else { + // defining new method + } + } +} + +const ENeedOverride = ( + name: string, + prev: Ast.ViaMember, + next: Ast.ViaMember, +) => Ast.TcError( + next.defLoc, + Ast.TEText(`Overriding "${name}" without "override"`), + Ast.TEText(`First defined at`), + Ast.TEViaMember(prev), + Ast.TEText(`Redefined at`), + Ast.TEViaMember(next), +); + +const ENeedAbstract = ( + name: string, + prev: Ast.ViaMember, + next: Ast.ViaMember, +) => Ast.TcError( + next.defLoc, + Ast.TEText( + `To override "${name}" it has to be "virtual" or "abstract"`, + ), + Ast.TEText(`First defined at`), + Ast.TEViaMember(prev), + Ast.TEText(`Redefined at`), + Ast.TEViaMember(next), +); + +const EEmptyOverride = (name: string, next: Ast.ViaMember) => Ast.TcError( + next.defLoc, + Ast.TEText(`To override "${name}" it has to exist`), + Ast.TEViaMember(next), +); diff --git a/src/next/types/receivers.ts b/src/next/types/receivers.ts new file mode 100644 index 0000000000..4fb024714f --- /dev/null +++ b/src/next/types/receivers.ts @@ -0,0 +1,394 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { Void } from "@/next/types/builtins"; +import { decodeStatementsLazy } from "@/next/types/statements"; +import { decodeDealiasTypeLazy } from "@/next/types/type"; +import { emptyTypeParams } from "@/next/types/type-params"; + +export function* getReceivers( + Lazy: Ast.ThunkBuilder, + selfTypeRef: () => Ast.SelfType, + typeName: Ast.TypeId, + traits: readonly Ast.Decl[], + receivers: readonly Ast.Receiver[], + scopeRef: () => Ast.CSource, +): Ast.Log { + const impExternals: Ast.Decl[] = []; + const impInternals: Ast.Decl[] = []; + const impBounces: Ast.Decl[] = []; + for (const { via, decl } of traits) { + const { external, internal, bounce } = decl.receivers; + impExternals.push(Ast.Decl(external, via)); + impInternals.push(Ast.Decl(internal, via)); + impBounces.push(Ast.Decl(bounce, via)); + } + + const localInternals: Ast.DeclMem< + [Ast.ReceiverSubKind, readonly Ast.Statement[]] + >[] = []; + const localExternals: Ast.DeclMem< + [Ast.ReceiverSubKind, readonly Ast.Statement[]] + >[] = []; + const localBounces: Ast.DeclMem< + [Ast.TypedParameter, readonly Ast.Statement[]] + >[] = []; + for (const receiver of receivers) { + const { selector, statements, loc } = receiver; + const via = Ast.ViaMemberOrigin(typeName.text, loc); + switch (selector.kind) { + case "internal": + case "external": { + const arr = + selector.kind === "internal" + ? localInternals + : localExternals; + arr.push(Ast.DeclMem([selector.subKind, statements], via)); + continue; + } + case "bounce": { + localBounces.push( + Ast.DeclMem([selector.param, statements], via), + ); + } + } + } + return { + bounce: yield* mergeBounce( + Lazy, + selfTypeRef, + typeName, + impBounces, + localBounces, + scopeRef, + ), + external: yield* mergeReceivers( + Lazy, + selfTypeRef, + typeName, + impExternals, + localExternals, + scopeRef, + ), + internal: yield* mergeReceivers( + Lazy, + selfTypeRef, + typeName, + impInternals, + localInternals, + scopeRef, + ), + }; +} + +function* mergeReceivers( + Lazy: Ast.ThunkBuilder, + selfTypeRef: () => Ast.SelfType, + typeName: Ast.TypeId, + imported: readonly Ast.Decl[], + local: Ast.DeclMem< + readonly [Ast.ReceiverSubKind, readonly Ast.Statement[]] + >[], + scopeRef: () => Ast.CSource, +): Ast.Log { + const allMessage: Ast.DeclMem[] = []; + let allMessageAny: undefined | Ast.DeclMem; + let allStringAny: undefined | Ast.DeclMem; + let allEmpty: undefined | Ast.DeclMem; + + // imported + for (const { via: viaTrait, decl } of imported) { + const { message, messageAny, stringAny, empty } = decl; + for (const { via, decl } of message) { + const nextVia = Ast.ViaMemberTrait( + typeName.text, + viaTrait.defLoc, + via, + ); + // we don't check for duplicates in receivers here, because + // the thing that matters is they have different opcodes + allMessage.push(Ast.DeclMem(decl, nextVia)); + } + if (messageAny) { + const nextVia = Ast.ViaMemberTrait( + typeName.text, + viaTrait.defLoc, + messageAny.via, + ); + if (allMessageAny) { + yield ERedefineReceiver( + "fallback binary", + allMessageAny.via, + nextVia, + ); + } + allMessageAny = Ast.DeclMem(messageAny.decl, nextVia); + } + if (stringAny) { + const nextVia = Ast.ViaMemberTrait( + typeName.text, + viaTrait.defLoc, + stringAny.via, + ); + if (allStringAny) { + yield ERedefineReceiver( + "fallback string", + allStringAny.via, + nextVia, + ); + } + allStringAny = Ast.DeclMem(stringAny.decl, nextVia); + } + if (empty) { + const nextVia = Ast.ViaMemberTrait( + typeName.text, + viaTrait.defLoc, + empty.via, + ); + if (allEmpty) { + yield ERedefineReceiver("empty", allEmpty.via, nextVia); + } + allEmpty = Ast.DeclMem(empty.decl, nextVia); + } + } + + // local + for (const { + via, + decl: [subKind, body], + } of local) { + const statements = (params: Ast.CParameters) => decodeStatementsLazy( + Lazy, + via.defLoc, + body, + () => Ast.CTMethod( + true, + emptyTypeParams, + selfTypeRef(), + params, + Lazy({ + callback: function* () { + return Void; + }, + context: [], + loc: via.defLoc, + recover: Void, + }) + ), + true, + scopeRef, + ); + switch (subKind.kind) { + case "simple": { + const { name, type, loc } = subKind.param; + const decodedLazy = decodeDealiasTypeLazy( + Lazy, + emptyTypeParams, + type, + scopeRef, + ); + const decoded = yield* decodedLazy(); + const parameters = Ast.CParameters( + [Ast.CParameter(name, decodedLazy, loc)], + name.kind === 'id' ? new Set([name.text]) : new Set() + ); + if (decoded.kind === "basic" && decoded.type.kind === "TySlice") { + if (allMessageAny) { + yield ERedefineReceiver( + "fallback binary", + allMessageAny.via, + via, + ); + } + allMessageAny = Ast.DeclMem( + Ast.CReceiverMessageAny(name, statements(parameters)), + via, + ); + } else if (decoded.kind === "basic" && decoded.type.kind === "TypeString") { + if (allStringAny) { + yield ERedefineReceiver( + "fallback string", + allStringAny.via, + via, + ); + } + allStringAny = Ast.DeclMem( + Ast.CReceiverStringAny(name, statements(parameters)), + via, + ); + } else if (decoded.kind === "type_ref") { + allMessage.push( + Ast.DeclMem( + Ast.CReceiverMessage(name, decoded, statements(parameters)), + via, + ), + ); + } else { + yield EInvalidRecv(via.defLoc); + } + continue; + } + case "fallback": { + if (allEmpty) { + yield ERedefineReceiver( + "fallback string", + allEmpty.via, + via, + ); + } + const parameters = Ast.CParameters([], new Set()); + allEmpty = Ast.DeclMem(Ast.CReceiverEmpty(statements(parameters)), via); + continue; + } + case "comment": { + const parameters = Ast.CParameters([], new Set()); + allMessage.push( + Ast.DeclMem( + Ast.CReceiverString(subKind.comment.value, statements(parameters)), + via, + ), + ); + continue; + } + } + } + + return { + message: allMessage, + messageAny: allMessageAny, + stringAny: allStringAny, + empty: allEmpty, + }; +} + +function* mergeBounce( + Lazy: Ast.ThunkBuilder, + selfTypeRef: () => Ast.SelfType, + typeName: Ast.TypeId, + imported: readonly Ast.Decl[], + local: readonly Ast.DeclMem< + [Ast.TypedParameter, readonly Ast.Statement[]] + >[], + scopeRef: () => Ast.CSource, +): Ast.Log { + const allMessage: Ast.DeclMem[] = []; + let allMessageAny: undefined | Ast.DeclMem; + + // imported + for (const { + via: viaTrait, + decl: { message, messageAny }, + } of imported) { + for (const { via, decl } of message) { + const nextVia = Ast.ViaMemberTrait( + typeName.text, + viaTrait.defLoc, + via, + ); + // we don't check for duplicates in receivers here, because + // the thing that matters is they have different opcodes + allMessage.push(Ast.DeclMem(decl, nextVia)); + } + if (messageAny) { + const nextVia = Ast.ViaMemberTrait( + typeName.text, + viaTrait.defLoc, + messageAny.via, + ); + if (allMessageAny) { + yield ERedefineReceiver( + "fallback binary", + allMessageAny.via, + nextVia, + ); + } + allMessageAny = Ast.DeclMem(messageAny.decl, nextVia); + } + } + + // local + for (const { + via, + decl: [{ name, type, loc }, body], + } of local) { + const decodedLazy = decodeDealiasTypeLazy( + Lazy, + emptyTypeParams, + type, + scopeRef, + ); + const decoded = yield* decodedLazy(); + const parameters = Ast.CParameters( + [Ast.CParameter(name, decodedLazy, loc)], + name.kind === 'id' ? new Set([name.text]) : new Set() + ); + const statements = decodeStatementsLazy( + Lazy, + via.defLoc, + body, + () => Ast.CTMethod( + true, + emptyTypeParams, + selfTypeRef(), + parameters, + Lazy({ + callback: function* () { + return Void; + }, + context: [], + loc: via.defLoc, + recover: Void, + }) + ), + true, + scopeRef, + ); + if (decoded.kind === "basic" && decoded.type.kind === "TySlice") { + if (allMessageAny) { + yield ERedefineReceiver( + "fallback binary", + allMessageAny.via, + via, + ); + } + allMessageAny = Ast.DeclMem( + Ast.CReceiverMessageAny(name, statements), + via, + ); + } else if ( + decoded.kind === "type_ref" || + decoded.kind === "TypeBounced" + ) { + allMessage.push( + Ast.DeclMem(Ast.CReceiverMessage(name, decoded, statements), via), + ); + } else { + yield EInvalidRecv(via.defLoc); + } + } + + return { + message: allMessage, + messageAny: allMessageAny, + }; +} + +const EInvalidRecv = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText( + `Receiver's parameter must be a message type, Slice, or String`, + ), +); + +const ERedefineReceiver = ( + kind: string, + prev: Ast.ViaMember, + next: Ast.ViaMember, +) => Ast.TcError( + next.defLoc, + Ast.TEText(`There already is a ${kind} receiver`), + Ast.TEText(`First defined at`), + Ast.TEViaMember(prev), + Ast.TEText(`Redefined at`), + Ast.TEViaMember(next), +); diff --git a/src/next/types/statements.ts b/src/next/types/statements.ts new file mode 100644 index 0000000000..6dca49171a --- /dev/null +++ b/src/next/types/statements.ts @@ -0,0 +1,731 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-expressions */ +import * as Ast from "@/next/ast"; +import { throwInternal } from "@/error/errors"; +import { Bool, builtinAugmented, Int } from "@/next/types/builtins"; +import { decodeExprCtx } from "@/next/types/expression"; +import { convertExprToLValue } from "@/next/types/lvalue"; +import { + assignType, + dealiasType, + decodeType, + decodeTypeLazy, + checkFnCall, +} from "@/next/types/type"; +import { + anyEff, + exitEff, + emptyEff, + allEff, + hasStorageAccess as isStorageAccess, +} from "@/next/types/effects"; +import { emptyTypeParams } from "@/next/types/type-params"; + +export function decodeStatementsLazy( + Lazy: Ast.ThunkBuilder, + loc: Ast.Loc, + statements: readonly Ast.Statement[], + fnTypeRef: () => Ast.CTFunction | Ast.CTMethod, + // typeParams: Ast.CTypeParams, + // selfTypeRef: () => undefined | Ast.SelfType, + // returnType: Ast.Thunk, + isInit: boolean, + scopeRef: () => Ast.CSource, + // localScopeRef: ReadonlyMap, +) { + return Lazy({ + callback: function* (Lazy) { + const fnType = fnTypeRef(); + const selfType = fnType.kind === "DecodedMethodType" + ? fnType.self + : undefined; + const required = isInit + ? yield* getRequired(selfType) + : undefined; + const localScopeRef: Map = new Map(); + for (const { loc, name, type } of fnType.params.order) { + if (name.kind === 'id') { + localScopeRef.set(name.text, [yield* type(), loc]); + } + } + const ctx: Context = { + Lazy, + localScopeRef, + required, + returnType: yield* fnType.returnType(), + scopeRef, + selfType, + typeParams: fnType.typeParams, + }; + const res = yield* decodeStmts(statements, ctx, emptyEff); + return Ast.CStatementsAux(res.value, res.effects); + }, + context: [Ast.TEText("checking statements")], + loc, + recover: undefined, + }); +} + +const decodeStmts: Decode< + readonly Ast.Statement[], + readonly Ast.CStmt[] +> = function* (nodes, ctx, eff) { + const results: Ast.CStmt[] = []; + let state = [ctx, eff] as const; + for (const node of nodes) { + const [ctx, eff] = state; + const result = yield* decodeStatement(node, ctx, eff); + results.push(result.value); + state = [result.context, allEff([eff, result.effects])]; + } + const [context, effects] = state; + return Result(results, context, effects); +}; + +const decodeStatement: Decode = function ( + stmt, + ctx, + eff, +) { + switch (stmt.kind) { + case "statement_let": + return decodeLet(stmt, ctx, eff); + case "statement_return": + return decodeReturn(stmt, ctx, eff); + case "statement_expression": + return decodeExpression(stmt, ctx, eff); + case "statement_assign": + return decodeAssign(stmt, ctx, eff); + case "statement_augmentedassign": + return decodeAssignAugmented(stmt, ctx, eff); + case "statement_condition": + return decodeCondition(stmt, ctx, eff); + case "statement_while": + return decodeWhile(stmt, ctx, eff); + case "statement_until": + return decodeUntil(stmt, ctx, eff); + case "statement_repeat": + return decodeRepeat(stmt, ctx, eff); + case "statement_try": + return decodeTry(stmt, ctx, eff); + case "statement_foreach": + return decodeForeach(stmt, ctx, eff); + case "statement_destruct": + return decodeDestruct(stmt, ctx, eff); + case "statement_block": + return decodeBlock(stmt, ctx, eff); + } +}; + +const decodeLet: Decode = function* ( + node, + ctx, + eff, +) { + const expr = yield* decodeExprCtx(node.expression, ctx); + const result = Ast.CStmtLet(node.name, expr.value, node.loc); + if (node.type) { + const ascribed = yield* decodeType( + ctx.typeParams, + node.type, + ctx.scopeRef().typeDecls, + ); + yield* assignType( + expr.value.loc, + emptyTypeParams, + ascribed, + expr.value.computedType, + false, + ); + const newCtx = yield* defineVar(node.name, ascribed, ctx); + return Result(result, newCtx, expr.eff); + } else { + const newCtx = yield* defineVar(node.name, expr.value.computedType, ctx); + return Result(result, newCtx, expr.eff); + } +}; + +const decodeReturn: Decode = function* (node, ctx, eff) { + if (ctx.required) { + const missing = [...ctx.required].filter((p) => !eff.mustSetSelf.has(p)); + for (const fieldName of missing) { + yield EMissingSelfInit(fieldName, node.loc); + } + } + const expr = yield* checkReturnExpr(node.expression, ctx); + return Result( + Ast.CStmtReturn(expr?.value, node.loc), + ctx, + exitEff(expr ? expr.eff : emptyEff), + ); +}; +const EMissingSelfInit = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Field "self.${name}" is not initialized by this moment`), +); +function* checkReturnExpr(node: Ast.Expression | undefined, ctx: Context) { + if (!node) { + return undefined; + } + const expr = yield* decodeExprCtx(node, ctx); + yield* assignType( + expr.value.loc, + emptyTypeParams, + ctx.returnType, + expr.value.computedType, + false, + ); + return expr; +} + + +const decodeExpression: Decode< + Ast.StatementExpression, + Ast.CStmtExpression +> = function* (node, ctx, eff) { + const expr = yield* decodeExprCtx(node.expression, ctx); + return Result( + Ast.CStmtExpression(expr.value, node.loc), + ctx, + expr.eff, + ); +}; + +const decodeAssign: Decode< + Ast.StatementAssign, + Ast.CStmtAssign | Ast.CStmtExpression +> = function* (node, ctx, eff) { + const right = yield* decodeExprCtx(node.expression, ctx); + const left = yield* decodeExprCtx(node.path, ctx); + const path = yield* convertExprToLValue(left.value); + if (!path) { + return Result( + Ast.CStmtExpression(right.value, node.loc), + ctx, + allEff([left.eff, right.eff]), + ); + } + + yield* assignType( + path.loc, + emptyTypeParams, + path.computedType, + right.value.computedType, + false, + ); + const argEffs = allEff([left.eff, right.eff]); + const isAssignToStorage = isStorageAccess(path, ctx.selfType); + const newEff: Ast.Effects = { + ...argEffs, + mayWrite: isAssignToStorage || argEffs.mayWrite, + }; + return Result(Ast.CStmtAssign(path, right.value, node.loc), ctx, newEff); +}; + +const decodeAssignAugmented: Decode< + Ast.StatementAugmentedAssign, + Ast.CStmtAugmentedAssign | Ast.CStmtExpression +> = function* (node, ctx, eff) { + const right = yield* decodeExprCtx(node.expression, ctx); + const left = yield* decodeExprCtx(node.path, ctx); + const path = yield* convertExprToLValue(left.value); + if (!path) { + return Result(Ast.CStmtExpression(right.value, node.loc), ctx, eff); + } + + const fnType = builtinAugmented.get(node.op); + if (!fnType) { + return throwInternal("Builtin operator is not in the map"); + } + yield* checkFnCall(node.loc, fnType, [ + [left.value.loc, left.value.computedType], + [right.value.loc, right.value.computedType], + ]); + + const argEffs = allEff([left.eff, right.eff]); + const isAssignToStorage = isStorageAccess(path, ctx.selfType); + const newEff: Ast.Effects = { + ...argEffs, + mayRead: isAssignToStorage || argEffs.mayRead, + mayWrite: isAssignToStorage || argEffs.mayWrite, + }; + return Result( + Ast.CStmtAugmentedAssign(node.op, path, right.value, node.loc), + ctx, + newEff, + ); +}; + +const decodeCondition: Decode = + function* (node, ctx, eff) { + const condition = yield* decodeExprCtx(node.condition, ctx); + yield* assignType( + condition.value.loc, + emptyTypeParams, + Bool, + condition.value.computedType, + false, + ); + const trueRes = yield* decodeStmts(node.trueStatements, ctx, eff); + const falseRes = yield* checkElse(node.falseStatements, ctx, eff); + return Result( + Ast.CStmtCondition( + condition.value, + trueRes.value, + falseRes.value, + node.loc, + ), + ctx, + allEff([ + condition.eff, + anyEff([trueRes.effects, falseRes.effects])], + ), + ); + }; +const checkElse: Decode< + undefined | readonly Ast.Statement[], + undefined | readonly Ast.CStmt[] +> = function* (node, ctx, eff) { + if (typeof node === 'undefined') { + return Result(undefined, ctx, emptyEff); + } + return yield* decodeStmts(node, ctx, eff); +} +const decodeWhile: Decode = function* ( + node, + ctx, + eff, +) { + const condition = yield* decodeExprCtx(node.condition, ctx); + yield* assignType( + condition.value.loc, + emptyTypeParams, + Bool, + condition.value.computedType, + false, + ); + const result = yield* decodeStmts(node.statements, ctx, eff); + // might be executed zero times, so it doesn't matter + // if it always returns, or assigns to `self` + return Result( + Ast.CStmtWhile(condition.value, result.value, node.loc), + ctx, + allEff([condition.eff, anyEff([result.effects, emptyEff])]), + ); +}; + +const decodeUntil: Decode = function* ( + node, + ctx, + eff, +) { + const condition = yield* decodeExprCtx(node.condition, ctx); + yield* assignType( + condition.value.loc, + emptyTypeParams, + Bool, + condition.value.computedType, + false, + ); + const result = yield* decodeStmts(node.statements, ctx, eff); + return Result( + Ast.CStmtUntil(condition.value, result.value, node.loc), + ctx, + allEff([result.effects, condition.eff, anyEff([result.effects, emptyEff])]), + ); +}; + +const decodeRepeat: Decode = + function* (node, ctx, eff) { + const iterations = yield* decodeExprCtx(node.iterations, ctx); + yield* assignType( + iterations.value.loc, + emptyTypeParams, + Int, + iterations.value.computedType, + false, + ); + const result = yield* decodeStmts(node.statements, ctx, eff); + // might be executed zero times, so it doesn't matter + // if it always returns, or assigns to `self` + return Result( + Ast.CStmtRepeat(iterations.value, result.value, node.loc), + ctx, + allEff([iterations.eff, anyEff([result.effects, emptyEff])]), + ); + }; + +const decodeTry: Decode = function* ( + node, + ctx, + eff, +) { + const tryRes = yield* decodeStmts(node.statements, ctx, eff); + if (node.catchBlock) { + const newCtx = yield* defineVar(node.catchBlock.name, Int, ctx); + const catchRes = yield* decodeStmts( + node.catchBlock.statements, + newCtx, + eff, + ); + const catchBlock = Ast.CCatchBlock(node.catchBlock.name, catchRes.value); + return Result( + Ast.CStmtTry(tryRes.value, catchBlock, node.loc), + ctx, + anyEff([tryRes.effects, catchRes.effects]), + ); + } else { + return Result( + Ast.CStmtTry(tryRes.value, undefined, node.loc), + ctx, + tryRes.effects, + ); + } +}; + +const decodeForeach: Decode = + function* (node, ctx, eff) { + const map = yield* decodeExprCtx(node.map, ctx); + const innerCtx = yield* defineForVars( + map.value.computedType, + node.keyName, + node.valueName, + ctx, + ); + const result = yield* decodeStmts(node.statements, innerCtx, eff); + return Result( + Ast.CStmtForEach( + node.keyName, + node.valueName, + map.value, + result.value, + node.loc, + ), + ctx, + allEff([map.eff, anyEff([result.effects, emptyEff])]), + ); + }; +function* defineForVars( + type: Ast.CType, + keyName: Ast.OptionalId, + valueName: Ast.OptionalId, + ctx: Context, +): Ast.Log { + if (type.kind === "map_type") { + const ctxKey = yield* defineVar(keyName, type.key, ctx); + const ctxKV = yield* defineVar(valueName, type.value, ctxKey); + return ctxKV; + } else if (type.kind === "TypeAlias") { + const childType = type.type; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (childType.kind === "NotDealiased") { + return throwInternal("Non-dealiased type in foreach"); + } + return yield* defineForVars(childType, keyName, valueName, ctx); + } else { + const ctxKey = yield* defineVar(keyName, Ast.CTRecover(), ctx); + const ctxKV = yield* defineVar(valueName, Ast.CTRecover(), ctxKey); + return ctxKV; + } +} + +const decodeDestruct: Decode< + Ast.StatementDestruct, + Ast.CStmtDestruct | Ast.CStmtExpression +> = function* (node, ctx, eff) { + const expr = yield* decodeExprCtx(node.expression, ctx); + + const typeArgs = yield* Ast.mapLog(node.typeArgs, function* (arg) { + return yield* decodeTypeLazy( + ctx.Lazy, + ctx.typeParams, + arg, + ctx.scopeRef, + )(); + }); + + const decl = yield* findStruct(node.type, typeArgs, ctx.scopeRef); + if (!decl) { + return Result(Ast.CStmtExpression(expr.value, node.loc), ctx, expr.eff); + } + + const ascribed = Ast.CTRef(node.type, decl, typeArgs, node.loc); + yield* assignType( + node.loc, + emptyTypeParams, + ascribed, + expr.value.computedType, + false, + ); + + // see checkFields in expression.ts + const [fields, newCtx] = yield* checkFields( + node.loc, + node.identifiers, + decl.fields, + node.ignoreUnspecifiedFields, + ctx, + ); + + return Result( + Ast.CStmtDestruct( + node.type, + fields, + node.ignoreUnspecifiedFields, + expr.value, + node.loc, + ), + newCtx, + expr.eff, + ); +}; +function* checkFields( + nodeLoc: Ast.Loc, + stmtFields: readonly (readonly [Ast.Id, Ast.OptionalId])[], + declFields: Ast.Ordered, + ignoreUnspecifiedFields: boolean, + ctx: Context, +): Ast.Log, Context]> { + const order: string[] = []; + const map: Map = new Map(); + for (const [field, variable] of stmtFields) { + const fieldName = field.text; + const prev = map.get(fieldName); + if (prev) { + const [, prevLoc] = prev; + yield EDuplicateField(fieldName, prevLoc, field.loc); + continue; + } + + const decl = declFields.map.get(fieldName); + if (!decl) { + yield ENoSuchField(fieldName, field.loc); + continue; + } + + order.push(fieldName); + + map.set(fieldName, [Ast.CDestructPattern(field, variable), field.loc]); + + ctx = yield* defineVar(variable, yield* decl.type(), ctx); + } + + if (!ignoreUnspecifiedFields) { + for (const fieldName of declFields.order) { + if (!map.has(fieldName)) { + yield EMissingField(fieldName, nodeLoc); + } + } + } + + const result = new Map( + [...map].map(([name, [pattern]]) => [name, pattern]), + ); + return [Ast.Ordered(order, result), ctx]; +} +const EMissingField = (name: string, prev: Ast.Loc) => Ast.TcError( + prev, + Ast.TEText(`Value for field "${name}" is missing`), + Ast.TECode(prev), +); +const ENoSuchField = (name: string, next: Ast.Loc) => Ast.TcError( + next, + Ast.TEText(`There is no field "${name}"`), Ast.TECode(next), +); +const EDuplicateField = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + prev, + Ast.TEText(`Duplicate field "${name}"`), + Ast.TEText(`Defined at:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); +function* findStruct( + id: Ast.TypeId, + typeArgs: Ast.CType[], + scopeRef: () => Ast.CSource, +) { + const decl = scopeRef().typeDecls.get(id.text); + if (!decl) { + return throwInternal("Bad ref from decoder"); + } + switch (decl.decl.kind) { + case "alias": { + const type = yield* dealiasType( + Ast.CTAliasRef(Ast.CNotDealiased(), id, typeArgs, id.loc), + scopeRef, + ); + if ( + type.kind === "type_ref" && + (type.type.kind === "struct" || type.type.kind === "message") + ) { + return type.type; + } else { + yield ENotDestructible(id.text, id.loc); + return undefined; + } + } + case "contract": + case "union": + case "trait": { + yield ENotDestructible(id.text, id.loc); + return undefined; + } + case "struct": + case "message": { + return decl.decl; + } + } +} +const ENotDestructible = (name: string, prev: Ast.Loc) => Ast.TcError( + prev, + Ast.TEText(`Type "${name}" doesn't `), Ast.TECode(prev), +); + +const decodeBlock: Decode = function* ( + node, + ctx, + eff, +) { + const result = yield* decodeStmts(node.statements, ctx, eff); + return Result( + Ast.CStmtBlock(result.value, node.loc), + ctx, + result.effects, + ); +}; + +type Decode = ( + node: T, + context: Context, + effAbove: Ast.Effects, +) => Ast.Log>; + +type Result = { + readonly value: U; + readonly context: Context; + readonly effects: Ast.Effects; +}; +const Result = ( + value: U, + context: Context, + effects: Ast.Effects, +): Result => Object.freeze({ value, context, effects }); + +type Context = { + readonly Lazy: Ast.ThunkBuilder; + readonly scopeRef: () => Ast.CSource; + readonly selfType: Ast.SelfType | undefined; + readonly required: undefined | ReadonlySet; + readonly typeParams: Ast.CTypeParams; + readonly returnType: Ast.CType; + readonly localScopeRef: ReadonlyMap; +}; + +function* defineVar( + node: Ast.OptionalId, + type: Ast.CType, + ctx: Context, +): Ast.Log { + if (node.kind === "wildcard") { + // there is nothing to define for a wildcard + return ctx; + } + + if (node.text === "self") { + yield ENoDefineSelf(node.loc); + return ctx; + } + + const prev = ctx.localScopeRef.get(node.text); + if (prev) { + const [, prevLoc] = prev; + yield ERedefineVar(node.text, prevLoc, node.loc); + return ctx; + } + + const constant = ctx.scopeRef().constants.get(node.text); + if (constant) { + const prevLoc = constant.via.defLoc; + yield EShadowConst(node.text, prevLoc, node.loc); + return ctx; + } + + const localScopeRef = new Map(ctx.localScopeRef); + localScopeRef.set(node.text, [type, node.loc]); + return { ...ctx, localScopeRef }; +} +const ENoDefineSelf = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Cannot define a variable "self"`), +); +const ERedefineVar = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText(`Variable ${name} is already defined`), + Ast.TEText(`Defined at:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); +const EShadowConst = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText(`Variable ${name} shadows a global constant`), + Ast.TEText(`Defined at:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); + +function* getRequired( + selfType: Ast.SelfType | undefined, +): Ast.Log> { + if (!selfType) { + return new Set(); + } + const required: Set = new Set(); + switch (selfType.kind) { + case "type_ref": { + switch (selfType.type.kind) { + case "contract": + case "trait": { + const { fieldish } = yield* selfType.type.content(); + for (const [name, field] of fieldish.map) { + if (field.decl.kind === "field" && !field.decl.init) { + required.add(name); + } + } + return required; + } + case "struct": + case "message": + case "union": { + // no requirement to fill self on these, because they have + // no init() + return required; + } + } + // linter needs this + return required; + } + case "map_type": + case "TypeMaybe": + case "tuple_type": + case "tensor_type": + case "basic": { + return undefined; + } + } +} diff --git a/src/next/types/struct-fields.ts b/src/next/types/struct-fields.ts new file mode 100644 index 0000000000..44c4853bd5 --- /dev/null +++ b/src/next/types/struct-fields.ts @@ -0,0 +1,103 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { evalExpr } from "@/next/types/expr-eval"; +import { decodeExpr } from "@/next/types/expression"; +import { assignType, decodeTypeLazy } from "@/next/types/type"; +import { emptyTypeParams } from "@/next/types/type-params"; + +export function* decodeFields( + Lazy: Ast.ThunkBuilder, + fields: readonly Ast.FieldDecl[], + typeParams: Ast.CTypeParams, + scopeRef: () => Ast.CSource, +) { + const order: string[] = []; + const all: Map = new Map(); + for (const field of fields) { + const { initializer, loc } = field; + const name = field.name.text; + + const prev = all.get(name); + if (prev) { + const [prevLoc] = prev; + yield EDuplicateField(name, prevLoc, loc); + continue; + } + + const ascribedType = decodeTypeLazy( + Lazy, + typeParams, + field.type, + scopeRef, + ); + + const lazyExpr = decodeInitializerLazy( + Lazy, + loc, + typeParams, + ascribedType, + initializer, + undefined, + scopeRef, + ); + + order.push(name); + all.set(name, [loc, Ast.CField(ascribedType, lazyExpr)]); + } + + const map = new Map([...all].map(([name, [, field]]) => [name, field])); + return Ast.Ordered(order, map); +} + +export function decodeInitializerLazy( + Lazy: Ast.ThunkBuilder, + loc: Ast.Loc, + typeParams: Ast.CTypeParams, + ascribedType: Ast.Thunk, + initializer: Ast.Expression | undefined, + selfType: undefined | Ast.SelfType, + scopeRef: () => Ast.CSource, +) { + if (!initializer) { + return undefined; + } + return Lazy({ + callback: function* (Lazy) { + const expr = yield* decodeExpr( + Lazy, + typeParams, + initializer, + scopeRef, + selfType, + new Map(), + ); + const computed = expr.value.computedType; + const ascribed = yield* ascribedType(); + yield* assignType( + expr.value.loc, + emptyTypeParams, + ascribed, + computed, + false, + ); + return yield* evalExpr(expr.value, scopeRef); + }, + context: [Ast.TEText("evaluating initial field value")], + loc, + recover: undefined, + }); +} + +const EDuplicateField = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText(`Duplicate field ${name}`), + Ast.TEText(`New definition:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); diff --git a/src/next/types/struct.ts b/src/next/types/struct.ts new file mode 100644 index 0000000000..f4ba1113ab --- /dev/null +++ b/src/next/types/struct.ts @@ -0,0 +1,20 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { decodeFields } from "@/next/types/struct-fields"; +import { decodeTypeParams } from "@/next/types/type-params"; + +export function* decodeStruct( + Lazy: Ast.ThunkBuilder, + struct: Ast.StructDecl, + scopeRef: () => Ast.CSource, +): Ast.Log { + const typeParams = yield* decodeTypeParams(struct.typeParams); + const fields = yield* decodeFields( + Lazy, + struct.fields, + typeParams, + scopeRef, + ); + return Ast.CStruct(typeParams, fields); +} diff --git a/src/next/types/tlb.ts b/src/next/types/tlb.ts new file mode 100644 index 0000000000..c38c06e929 --- /dev/null +++ b/src/next/types/tlb.ts @@ -0,0 +1,32 @@ +// export function convertTypeToTlb( +// node: Ast.DecodedType, +// ) { +// switch (node.kind) { +// case "recover": { +// return undefined; +// } +// case "type_ref": { + +// } +// case "TypeAlias": { + +// } +// case "TypeParam": +// case "map_type": +// case "TypeBounced": +// case "TypeMaybe": +// case "tuple_type": +// case "tensor_type": +// case "TyInt": +// case "TySlice": +// case "TyCell": +// case "TyBuilder": +// case "unit_type": +// case "TypeVoid": +// case "TypeNull": +// case "TypeBool": +// case "TypeAddress": +// case "TypeString": +// case "TypeStringBuilder": +// } +// } diff --git a/src/next/types/trait.ts b/src/next/types/trait.ts new file mode 100644 index 0000000000..cb31401c95 --- /dev/null +++ b/src/next/types/trait.ts @@ -0,0 +1,97 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { getFieldishGeneral } from "@/next/types/fields"; +import { getInheritedTraits } from "@/next/types/traits-scope"; +import { getMethodsGeneral } from "@/next/types/methods"; +import { getReceivers } from "@/next/types/receivers"; + +export function* decodeTrait( + Lazy: Ast.ThunkBuilder, + trait: Ast.Trait, + scopeRef: () => Ast.CSource, +): Ast.Log { + const { attributes, declarations, name, loc } = trait; + const { constants, fields, methods, receivers } = declarations; + + const attr = attributes[0]; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (attr) { + yield ENoAttributes(attr.loc); + } + + // delayed until we get all traits and init + const contentLazy = Lazy({ + callback: function* (Lazy) { + const traits = yield* getInheritedTraits(trait.traits, scopeRef); + + // const contentRef = () => content; + const content: Ast.CTraitMembers = { + fieldish: yield* getFieldishGeneral( + Lazy, + traitSig, + name, + traits, + constants, + fields, + scopeRef, + ), + methods: yield* getMethodsGeneral( + Lazy, + traitSig, + name, + traits, + methods, + scopeRef, + ), + receivers: yield* getReceivers( + Lazy, + () => selfType, + name, + traits, + receivers, + scopeRef, + ), + }; + + return content; + }, + context: [Ast.TEText("checking inner scope of trait")], + loc, + recover, + }); + + const traitSig = Ast.CTrait(contentLazy); + + const selfType = Ast.SVTRef(trait.name, traitSig, [], trait.loc); + + return traitSig; +} + +const ENoAttributes = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Traits cannot have attributes`), +); + +const recover: Ast.CTraitMembers = { + fieldish: Ast.Ordered([], new Map()), + methods: new Map(), + receivers: { + bounce: { + message: [], + messageAny: undefined, + }, + internal: { + message: [], + messageAny: undefined, + stringAny: undefined, + empty: undefined, + }, + external: { + message: [], + messageAny: undefined, + stringAny: undefined, + empty: undefined, + }, + }, +}; diff --git a/src/next/types/traits-scope.ts b/src/next/types/traits-scope.ts new file mode 100644 index 0000000000..8320e48427 --- /dev/null +++ b/src/next/types/traits-scope.ts @@ -0,0 +1,36 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; + +export function* getInheritedTraits( + traits: readonly Ast.TypeId[], + scopeRef: () => Ast.CSource, +): Ast.Log[]> { + const decls = scopeRef().typeDecls; + const prevTraits: Ast.Decl[] = []; + for (const trait of traits) { + const name = trait.text; + const decl = decls.get(name); + if (!decl) { + yield EUndefinedTrait(name, trait.loc); + continue; + } + const { via, decl: traitDecl } = decl; + if (traitDecl.kind !== "trait") { + yield EOnlyTraits(trait.loc); + continue; + } + prevTraits.push(Ast.Decl(yield* traitDecl.content(), via)); + } + return prevTraits; +} + +const EUndefinedTrait = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Traits "${name}" is not defined`), +); + +const EOnlyTraits = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Can only inherit traits`), +); diff --git a/src/next/types/type-fn.ts b/src/next/types/type-fn.ts new file mode 100644 index 0000000000..7da9e075a9 --- /dev/null +++ b/src/next/types/type-fn.ts @@ -0,0 +1,58 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { decodeTypeParams } from "@/next/types/type-params"; +import { decodeDealiasTypeLazy } from "@/next/types/type"; +import { recoverName } from "@/next/types/name"; + +export function* decodeFnType( + Lazy: Ast.ThunkBuilder, + { typeParams, params, returnType }: Ast.TFunction, + scopeRef: () => Ast.CSource, +): Ast.Log { + const decodedTypeParams = yield* decodeTypeParams(typeParams); + const dealias = (type: Ast.Type) => { + return decodeDealiasTypeLazy(Lazy, decodedTypeParams, type, scopeRef); + }; + return Ast.CTFunction( + decodedTypeParams, + yield* decodeParams(dealias, params), + dealias(returnType), + ); +} + +export function* decodeParams( + dealias: (type: Ast.Type) => Ast.Thunk, + params: readonly Ast.TypedParameter[], +): Ast.Log { + const order: Ast.CParameter[] = []; + const set: Set = new Set(); + for (const param of params) { + const name = yield* decodeParamName(param.name, set); + order.push(Ast.CParameter(param.name, dealias(param.type), param.loc)); + if (typeof name !== "undefined") { + set.add(name); + } + } + return Ast.CParameters(order, set); +} + +function* decodeParamName( + node: Ast.OptionalId, + set: ReadonlySet, +): Ast.Log { + if (node.kind === "wildcard") { + return undefined; + } + const name = node.text; + if (!set.has(name)) { + return name; + } + yield EDuplicateParam(name, node.loc); + return recoverName(name, set); +} + +const EDuplicateParam = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Duplicate parameter "${name}"`), +); diff --git a/src/next/types/type-params.ts b/src/next/types/type-params.ts new file mode 100644 index 0000000000..64255b748c --- /dev/null +++ b/src/next/types/type-params.ts @@ -0,0 +1,29 @@ +import * as Ast from "@/next/ast"; +import { recoverName } from "@/next/types/name"; + +export const emptyTypeParams = Ast.CTypeParams([], new Set()); + +export function* decodeTypeParams( + ids: readonly Ast.TypeId[], +): Ast.Log { + const set: Set = new Set(); + const order: Ast.TypeId[] = []; + + for (const id of ids) { + if (set.has(id.text)) { + yield EDuplicateTypeParam(id.text, id.loc); + const newName = recoverName(id.text, set); + order.push(Ast.TypeId(newName, id.loc)); + } else { + set.add(id.text); + order.push(id); + } + } + + return Ast.CTypeParams(ids, set); +} + +const EDuplicateTypeParam = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Duplicate type parameter "${name}"`), +); diff --git a/src/next/types/type-print.ts b/src/next/types/type-print.ts new file mode 100644 index 0000000000..bba002262e --- /dev/null +++ b/src/next/types/type-print.ts @@ -0,0 +1,134 @@ +import type * as Ast from "@/next/ast"; + +export function printType(node: Ast.CType, allowRecover: boolean) { + function recN(nodes: readonly Ast.CType[]): undefined | string { + const results: string[] = []; + for (const node of nodes) { + const result = rec(node); + if (result) { + results.push(result); + } else { + return undefined; + } + } + return results.join(", "); + } + + function rec(node: Ast.CType): undefined | string { + switch (node.kind) { + case "recover": { + return allowRecover ? "$ERROR" : undefined; + } + case "type_ref": + case "TypeAlias": { + const name = node.name.text; + if (node.typeArgs.length === 0) { + return name; + } else { + const args = recN(node.typeArgs); + return args && `${name}<${args}>`; + } + } + case "TypeParam": { + return node.name.text; + } + case "map_type": { + const key = rec(node.key); + const value = rec(node.value); + return key && value && `Map<${key}, ${value}>`; + } + case "TypeBounced": { + return `bounced<${node.name.text}>`; + } + case "TypeMaybe": { + const type = rec(node.type); + return type && `Maybe<${type}>`; + } + case "tuple_type": + case "tensor_type": { + const typeArgs = recN(node.typeArgs); + return typeArgs && `[${typeArgs}]`; + } + case "basic": { + return printBasic(node.type) + } + } + } + + return rec(node); +} + +const printBasic = (node: Ast.BasicType): string => { + switch (node.kind) { + case "TyInt": { + return `Int${printIntFormat(node.format)}`; + } + case "TySlice": { + return `Slice${printSliceFormat(node.format)}`; + } + case "TyCell": { + return `Cell${printRemFormat(node.format)}`; + } + case "TyBuilder": { + return `Builder${printRemFormat(node.format)}`; + } + case "unit_type": { + return `()`; + } + case "TypeVoid": { + return `Void`; + } + case "TypeNull": { + return `Null`; + } + case "TypeBool": { + return `Bool`; + } + case "TypeAddress": { + return `Address`; + } + case "TypeStateInit": { + return `StateInit`; + } + case "TypeString": { + return `String`; + } + case "TypeStringBuilder": { + return `StringBuilder`; + } + } +}; + +const printIntFormat = (format: Ast.IntFormat): string => { + if ( + format.kind === "FInt" && + format.sign === "signed" && + format.width === 257 + ) { + return ""; + } + return ( + " as " + + (format.kind === "FVarInt" ? "var" : "") + + (format.sign === "unsigned" ? "uint" : "int") + + (format.kind === "FVarInt" ? format.width : format.width.toString()) + ); +}; + +const printSliceFormat = (format: Ast.SliceFormat): string => { + if (format.kind === "SFBits") { + // FIXME: bits not divisible by 8 + return ` as bytes${format.bits >> 3}`; + } else { + return printRemFormat(format); + } +}; + +const printRemFormat = (format: Ast.RemFormat): string => { + switch (format.kind) { + case "SFRemaining": + return ` as remaining`; + case "SFDefault": + return ``; + } +}; diff --git a/src/next/types/type.ts b/src/next/types/type.ts new file mode 100644 index 0000000000..481d6ae501 --- /dev/null +++ b/src/next/types/type.ts @@ -0,0 +1,1167 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { throwInternal } from "@/error/errors"; +import * as Ast from "@/next/ast"; +import { messageBuiltin, structBuiltin } from "@/next/types/builtins"; +import { emptyTypeParams } from "@/next/types/type-params"; +import { printType } from "@/next/types/type-print"; +import { zip } from "@/utils/array"; + +export const decodeTypeLazy = ( + Lazy: Ast.ThunkBuilder, + typeParams: Ast.CTypeParams, + type: Ast.Type, + scopeRef: () => Ast.CSource, +) => + Lazy({ + callback: () => decodeType(typeParams, type, scopeRef().typeDecls), + context: [Ast.TEText("checking type"), Ast.TECode(type.loc)], + loc: type.loc, + recover: Ast.CTRecover(), + }); + +export const decodeDealiasTypeLazy = ( + Lazy: Ast.ThunkBuilder, + typeParams: Ast.CTypeParams, + type: Ast.Type, + scopeRef: () => Ast.CSource, +) => + Lazy({ + callback: function* () { + const decoded = yield* decodeType( + typeParams, + type, + scopeRef().typeDecls, + ); + return yield* dealiasTypeAux(decoded, scopeRef().typeDecls); + }, + context: [Ast.TEText("checking type"), Ast.TECode(type.loc)], + loc: type.loc, + recover: Ast.CTRecover(), + }); + +export function* dealiasType(type: Ast.CType, scopeRef: () => Ast.CSource) { + return yield* dealiasTypeAux(type, scopeRef().typeDecls); +} + +export function* decodeTypeMap( + typeParams: Ast.CTypeParams, + type: Ast.TMap, + scopeRef: () => Ast.CSource, +) { + const { typeDecls } = scopeRef(); + const key = yield* decodeType(typeParams, type.key, typeDecls); + const value = yield* decodeType(typeParams, type.value, typeDecls); + return Ast.CTMap(key, value, type.loc); +} + +export function* decodeTypeSet( + typeParams: Ast.CTypeParams, + type: Ast.TMap, + scopeRef: () => Ast.CSource, +) { + const { typeDecls } = scopeRef(); + const key = yield* decodeType(typeParams, type.key, typeDecls); + const value = yield* decodeType(typeParams, type.value, typeDecls); + return Ast.CTMap(key, value, type.loc); +} + +export function decodeType( + typeParams: Ast.CTypeParams, + type: Ast.Type, + typeDecls: ReadonlyMap>, +) { + // decode all the types in an array + function* recN( + types: readonly Ast.Type[], + ): Ast.Log { + const results: Ast.CType[] = []; + for (const type of types) { + const result = yield* rec(type); + results.push(result); + } + return results; + } + + // decode a type + function* rec(type: Ast.Type): Ast.Log { + switch (type.kind) { + case "basic": { + return type; + } + case "tuple_type": { + const result = yield* recN(type.typeArgs); + return Ast.CTTuple(result, type.loc); + } + case "tensor_type": { + const result = yield* recN(type.typeArgs); + return Ast.CTTensor(result, type.loc); + } + case "map_type": { + // NB! modify along with decodeTypeMap above + const key = yield* rec(type.key); + const value = yield* rec(type.value); + return Ast.CTMap(key, value, type.loc); + } + case "TypeBounced": { + const child = yield* rec(type.type); + if (child.kind !== "type_ref" || child.typeArgs.length > 0) { + yield EBouncedMessage(type.loc); + return Ast.CTRecover(); + } + const typeEntry = typeDecls.get(child.name.text); + if (!typeEntry) { + yield EBouncedMessage(type.loc); + return Ast.CTRecover(); + } else if (typeEntry.decl.kind === "message") { + return Ast.CTBounced(child.name, type.loc); + } else { + yield EBouncedMessage(type.loc); + return Ast.CTRecover(); + } + } + case "TypeMaybe": { + const child = yield* rec(type.type); + return Ast.CTMaybe(child, type.loc); + } + case "cons_type": { + // this is where the meat of the procedure is + // cons can be either parameter, type reference, + // alias reference, or reference to undefined type + const name = type.name.text; + const arity = type.typeArgs.length; + + const args = yield* recN(type.typeArgs); + + // if it's in a list of type parameters, this + // is a parameter + if (typeParams.set.has(name)) { + // if we used type parameter generically, throw error + // because we do not support HKT + if (!(yield* matchArity(name, arity, 0, type.loc))) { + return Ast.CTRecover(); + } + return Ast.CTParamRef(type.name, type.loc); + } + + const typeEntry = typeDecls.get(name); + + // there is no such type at all! + if (!typeEntry) { + yield ETypeNotFound(name, type.loc); + return Ast.CTRecover(); + } + + // check number of type arguments does match + if ( + !(yield* matchArity( + name, + arity, + getArity(typeEntry.decl), + type.loc, + )) + ) { + return Ast.CTRecover(); + } + + switch (typeEntry.decl.kind) { + case "trait": { + yield ETraitNotType(type.loc); + return Ast.CTRecover(); + } + case "contract": { + // this is a ground type reference + return Ast.CTRef( + type.name, + typeEntry.decl, + [], + type.loc, + ); + } + case "struct": + case "message": + case "union": { + // this is a ground type reference + return Ast.CTRef( + type.name, + typeEntry.decl, + args, + type.loc, + ); + } + case "alias": { + // this is an alias reference + return Ast.CTAliasRef( + Ast.CNotDealiased(), + type.name, + args, + type.loc, + ); + } + } + } + } + } + + return rec(type); +} + +const getArity = (decl: Ast.CTypeDecl): number => { + switch (decl.kind) { + case "alias": + case "struct": + case "union": + return decl.typeParams.order.length; + case "contract": + case "trait": + case "message": + return 0; + } +}; + +const EBouncedMessage = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Only message types can be bounced<>`), +); + +const ETypeNotFound = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Type "${name}" is not defined`), +); + +function* matchArity( + name: string, + got: number, + expected: number, + loc: Ast.Loc, +): Ast.Log { + const result = got === expected; + if (!result) { + yield EArity(name, expected, got, loc); + } + return result; +} + +const EArity = ( + name: string, + expected: number, + got: number, + loc: Ast.Loc, +) => Ast.TcError( + loc, + Ast.TEText( + `Type "${name}" is expected to have ${expected} type arguments, got ${got}`, + ), +); + +const ETraitNotType = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Traits cannot be used as types`), +); + +const dealiasTypeAux = ( + type: Ast.CType, + typeDecls: ReadonlyMap>, +) => { + function* rec(type: Ast.CType): Ast.Log { + switch (type.kind) { + case "recover": { + return type; + } + case "type_ref": { + const args = yield* Ast.mapLog(type.typeArgs, rec); + return Ast.CTRef(type.name, type.type, args, type.loc); + } + case "TypeAlias": { + const alias = typeDecls.get(type.name.text); + if (!alias || alias.decl.kind !== "alias") { + return throwInternal( + "Type decoder must not return types with dangling references", + ); + } + // NB! if we could decode alias once, there might be + // a nested one too + const decoded = yield* rec( + substituteTypeArgs( + yield* alias.decl.type(), + alias.decl.typeParams, + yield* Ast.mapLog(type.typeArgs, rec), + ), + ); + return Ast.CTAliasRef( + decoded, + type.name, + type.typeArgs, + type.loc, + ); + } + case "TypeParam": { + return type; + } + case "map_type": { + const key = yield* rec(type.key); + const value = yield* rec(type.value); + return Ast.CTMap(key, value, type.loc); + } + case "TypeMaybe": { + const args = yield* rec(type.type); + return Ast.CTMaybe(args, type.loc); + } + case "tuple_type": { + const args = yield* Ast.mapLog(type.typeArgs, rec); + return Ast.CTTuple(args, type.loc); + } + case "tensor_type": { + const args = yield* Ast.mapLog(type.typeArgs, rec); + return Ast.CTTensor(args, type.loc); + } + case "basic": + case "TypeBounced": { + return type; + } + } + } + + return rec(type); +}; + +// NB! if substitute is used for something other than aliases, do not throwInternal on type.type +export const substituteTypeArgs = ( + type: Ast.CType, + params: Ast.CTypeParams, + args: readonly Ast.CType[], +): Ast.CType => { + if (params.order.length !== args.length) { + return throwInternal("Decoder didn't check alias arity"); + } + + const substMap = new Map( + zip(params.order, args).map(([param, arg]) => { + return [param.text, arg]; + }), + ); + + const recN = ( + types: readonly Ast.CType[], + ): readonly Ast.CType[] => { + return types.map((type) => rec(type)); + }; + + const rec = (type: Ast.CType): Ast.CType => { + switch (type.kind) { + case "TypeParam": { + const arg = substMap.get(type.name.text); + if (!arg) { + return throwInternal( + "Decoder didn't scope alias's type args", + ); + } + return arg; + } + case "type_ref": { + const args = recN(type.typeArgs); + return Ast.CTRef(type.name, type.type, args, type.loc); + } + case "TypeAlias": { + if (type.type.kind === "NotDealiased") { + const args = recN(type.typeArgs); + return Ast.CTAliasRef( + type.type, + type.name, + args, + type.loc, + ); + } else { + const args = recN(type.typeArgs); // ?? + return Ast.CTAliasRef( + rec(type.type), + type.name, + args, + type.loc, + ); + } + } + case "map_type": { + const key = rec(type.key); + const value = rec(type.value); + return Ast.CTMap(key, value, type.loc); + } + case "TypeMaybe": { + const args = rec(type.type); + return Ast.CTMaybe(args, type.loc); + } + case "tuple_type": { + const args = recN(type.typeArgs); + return Ast.CTTuple(args, type.loc); + } + case "tensor_type": { + const args = recN(type.typeArgs); + return Ast.CTTensor(args, type.loc); + } + case "recover": + case "basic": + case "TypeBounced": { + return type; + } + } + }; + + return rec(type); +}; + +export function* instantiateStruct( + typeName: Ast.TypeId, + typeArgs: readonly Ast.CType[], + // NB! these are type params from enclosing scope + typeParams: Ast.CTypeParams, + scopeRef: () => Ast.CSource, +): Ast.Log< + undefined | { type: Ast.CTRef; fields: Ast.Ordered } +> { + const decl = scopeRef().typeDecls.get(typeName.text); + switch (decl?.decl.kind) { + case undefined: { + yield ENoSuchType(typeName.text, typeName.loc); + return undefined; + } + case "contract": { + yield ENotInstantiable(typeName.text, typeName.loc); + return undefined; + } + case "trait": + case "union": { + yield ENotInstantiable(typeName.text, typeName.loc); + return undefined; + } + case "struct": + case "message": { + const declArity = + decl.decl.kind === "message" + ? 0 + : decl.decl.typeParams.order.length; + const useArity = typeArgs.length; + if (declArity !== useArity) { + yield ETypeArity( + typeName.text, + typeName.loc, + declArity, + useArity, + ); + return undefined; + } + return { + type: Ast.CTRef(typeName, decl.decl, typeArgs, typeName.loc), + fields: decl.decl.fields, + }; + } + case "alias": { + const declArity = decl.decl.typeParams.order.length; + const useArity = typeArgs.length; + if (declArity !== useArity) { + yield ETypeArity( + typeName.text, + typeName.loc, + declArity, + useArity, + ); + return undefined; + } + const type = yield* dealiasType( + Ast.CTAliasRef( + Ast.CNotDealiased(), + typeName, + typeArgs, + typeName.loc, + ), + scopeRef, + ); + if (type.kind !== "type_ref") { + yield ENotInstantiable(typeName.text, typeName.loc); + return undefined; + } + return yield* instantiateStruct( + type.name, + type.typeArgs, + typeParams, + scopeRef, + ); + } + } +} +const ENoSuchType = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Type ${name} is not defined`), +); +const ENotInstantiable = (name: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Cannot create value of type ${name}`), +); +const ETypeArity = ( + name: string, + loc: Ast.Loc, + declArity: number, + useArity: number, +) => Ast.TcError( + loc, + Ast.TEText( + `Type ${name} expects ${declArity} arguments, got ${useArity}`, + ), +); + +export function typeParamsToSubst(typeParams: Ast.CTypeParams) { + const subst: Map = new Map( + typeParams.order.map((name) => [name.text, Ast.CNotSet()]), + ); + return subst; +} + +export function* substToTypeArgMap( + loc: Ast.Loc, + subst: Map, +): Ast.Log { + const res = substToTypeArgMapAux(subst); + if (res.ok) { + return res.args; + } else { + for (const name of res.names) { + yield EFreeTypeParam(name, loc); + } + return undefined; + } +} + +function substToTypeArgMapAux( + subst: Map, +): { ok: true; args: Ast.TypeArgs } | { ok: false; names: readonly string[] } { + const args: Map = new Map(); + const names: string[] = []; + for (const [name, type] of subst) { + if (type.kind === "not-set") { + names.push(name); + } else { + args.set(name, type); + } + } + if (names.length > 0) { + return { ok: false, names }; + } else { + return { ok: true, args }; + } +} + +export function* assignType( + loc: Ast.Loc, + toFreeTypeParam: Ast.CTypeParams, + to: Ast.CType, + from: Ast.CType, + strict: boolean, +): Ast.Log { + const subst = typeParamsToSubst(toFreeTypeParam); + const result = assignTypeAux(to, from, subst, strict); + if (result.kind === "failure") { + yield EMismatch(result.tree, loc); + return undefined; + } + return yield* substToTypeArgMap(loc, subst); +} +const EFreeTypeParam = (paramName: string, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`No substitution for type parameter "${paramName}"`), +); +const EMismatch = (tree: Ast.MatchTree, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Type mismatch`), Ast.TEMismatch(tree), +); + +type AssignResult = AssignSuccess | AssignFailure; +type AssignSuccess = { + readonly kind: "success"; +}; +const AssignSuccess = (): AssignSuccess => Object.freeze({ kind: "success" }); +type AssignFailure = { + readonly kind: "failure"; + readonly tree: Ast.MatchTree; +}; +const AssignFailure = (tree: Ast.MatchTree): AssignFailure => + Object.freeze({ kind: "failure", tree }); + +type Log = Generator; + +export function assignTypeAux( + to: Ast.CType, + from: Ast.CType, + subst: Map, + strict: boolean, +) { + function* recN( + tos: readonly Ast.CType[], + froms: readonly Ast.CType[], + ): Log { + if (tos.length !== froms.length) { + return throwInternal( + "Arg count does not match after type decoding", + ); + } + let result = true; + for (const [to, from] of zip(tos, froms)) { + const res = yield* rec(to, from); + // NB! cannot merge into one line, otherwise it will + // short-circuit + result &&= res; + } + return result; + } + + function* rec(to: Ast.CType, from: Ast.CType): Log { + const result = collectMismatches(to, from); + if (result.kind === "failure") { + yield result.tree; + return false; + } + return true; + } + + function collectMismatches( + to: Ast.CType, + from: Ast.CType, + ): AssignResult { + const gen = check(to, from); + const results: Ast.MatchTree[] = []; + for (;;) { + const res = gen.next(); + if (!res.done) { + // collect all errors (if any) + results.push(res.value); + continue; + } + const toStr = printType(to, false); + const fromStr = printType(from, false); + if (!toStr || !fromStr) { + // if types have errors, we don't print the error + // because it resulted from another error + return AssignSuccess(); + } + if (res.value && !results.length) { + return AssignSuccess(); + } + return AssignFailure(Ast.MatchTree(to, from, results)); + } + } + + function* check(to: Ast.CType, from: Ast.CType): Log { + if (from.kind === "TypeAlias") { + if (from.type.kind === "NotDealiased") { + return throwInternal("Decoder returned aliased type"); + } + from = from.type; + return yield* rec(to, from); + } + switch (to.kind) { + case "recover": { + return true; + } + case "TypeAlias": { + if (to.type.kind === "NotDealiased") { + return throwInternal("Decoder returned aliased type"); + } + to = to.type; + return yield* rec(to, from); + } + case "type_ref": { + return ( + to.kind === from.kind && + to.name.text === from.name.text && + (yield* recN(to.typeArgs, from.typeArgs)) + ); + } + case "tuple_type": + case "tensor_type": { + return ( + to.kind === from.kind && + (yield* recN(to.typeArgs, from.typeArgs)) + ); + } + case "TypeParam": { + const typeVar = subst.get(to.name.text); + if (!typeVar) { + return to.kind === from.kind && to.name.text === from.name.text; + } else if (typeVar.kind === "not-set") { + subst.set(to.name.text, from); + return true; + } else { + return yield* rec(typeVar, from); + } + } + case "TypeBounced": { + return to.kind === from.kind && to.name.text === from.name.text; + } + case "TypeMaybe": { + return ( + // Maybe := Null + (!strict && from.kind === "basic" && from.type.kind === "TypeNull") || + ( + to.kind === from.kind + // Maybe := Maybe + ? yield* rec(to.type, from.type) + // Maybe := Cell + : !strict && (yield* rec(to.type, from)) + ) + ); + } + case "map_type": { + return ( + (!strict && from.kind === "basic" && from.type.kind === "TypeNull") || + (to.kind === from.kind && + (yield* rec(to.key, from.key)) && + (yield* rec(to.value, from.value))) + ); + } + case "basic": { + return from.kind === to.kind && to.type.kind === from.type.kind; + } + } + } + + return collectMismatches(to, from); +} + +export function* mgu( + left: Ast.CType, + right: Ast.CType, + loc: Ast.Loc, +): Ast.Log { + function* rec( + left: Ast.CType, + right: Ast.CType, + ): Ast.Log { + if (right.kind === "TypeAlias") { + if (right.type.kind === "NotDealiased") { + return throwInternal("Decoder returned aliased type"); + } + right = right.type; + return yield* rec(left, right); + } + if (left.kind === "TypeAlias") { + if (left.type.kind === "NotDealiased") { + return throwInternal("Decoder returned aliased type"); + } + left = left.type; + return yield* rec(left, left); + } + const resultL = assignTypeAux(left, right, new Map(), false); + if (resultL.kind === "success") { + return left; + } + const resultR = assignTypeAux(right, left, new Map(), false); + if (resultR.kind === "success") { + return right; + } + if (right.kind === "basic" && right.type.kind === "TypeNull") { + return Ast.CTMaybe(left, loc); + } + if (left.kind === "basic" && left.type.kind === "TypeNull") { + return Ast.CTMaybe(right, loc); + } + yield ENotUnifiable(resultL.tree, loc); + return Ast.CTRecover(); + } + + return yield* rec(left, right); +} +const ENotUnifiable = (tree: Ast.MatchTree, loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`Branches of condition have mismatched types`), + Ast.TEMismatch(tree), +); + +export type CallResult = { + readonly returnType: Ast.CType; + readonly typeArgMap: Ast.TypeArgs; +}; + +export function* checkFnCall( + loc: Ast.Loc, + fnType: Ast.CTFunction | Ast.CTMethod, + args: readonly (readonly [Ast.Loc, Ast.CType])[], +): Ast.Log { + const { typeParams, params, returnType } = fnType; + + const subst = typeParamsToSubst(typeParams); + + for (const [index, { name, type, loc }] of params.order.entries()) { + const pair = args[index]; + if (!pair) { + // not enough args + break; + } + const [argLoc, arg] = pair; + const result = assignTypeAux(yield* type(), arg, subst, false); + if (result.kind === "failure") { + yield EMismatchArg(getParamName(name, index), result.tree, argLoc); + } + } + + // not enough or too many args + if (params.order.length !== args.length) { + yield EFnArity("Function", params.order.length, args.length, loc); + } + + const typeArgsMap = yield* substToTypeArgMap(loc, subst); + + if (!typeArgsMap) { + return { + returnType: Ast.CTRecover(), + typeArgMap: new Map(), + }; + } + + const typeArgs: Ast.CType[] = []; + for (const param of typeParams.order) { + const arg = typeArgsMap.get(param.text); + if (!arg) { + return throwInternal("substToTypeArgMap lost param"); + } + typeArgs.push(arg); + } + + const retType = substituteTypeArgs( + yield* returnType(), + typeParams, + typeArgs, + ); + + return { returnType: retType, typeArgMap: typeArgsMap }; +} +const EMismatchArg = ( + name: string, + tree: Ast.MatchTree, + loc: Ast.Loc, +) => Ast.TcError( + loc, + Ast.TEText(`Type doesn't match type of parameter ${name}`), + Ast.TEMismatch(tree), +); + +function getParamName(name: Ast.OptionalId, index: number) { + return name.kind === "id" ? name.text : `#${index + 1}`; +} + +const EFnArity = ( + kind: string, + expected: number, + got: number, + loc: Ast.Loc, +) => Ast.TcError( + loc, + Ast.TEText( + `${kind} is expected to have ${expected} type arguments, got ${got}`, + ), +); + +export function* checkFnCallWithArgs( + Lazy: Ast.ThunkBuilder, + loc: Ast.Loc, + fnType: Ast.CTFunction | undefined, + ascribedTypeArgs: readonly Ast.CType[], + args: readonly (readonly [Ast.Loc, Ast.CType])[], +): Ast.Log { + if (!fnType) { + yield ENoFunction(loc); + return { returnType: Ast.CTRecover(), typeArgMap: new Map() }; + } + if (ascribedTypeArgs.length === 0) { + return yield* checkFnCall(loc, fnType, args); + } + if (fnType.typeParams.order.length !== ascribedTypeArgs.length) { + return { returnType: Ast.CTRecover(), typeArgMap: new Map() }; + } + const result = yield* checkFnCall( + loc, + substFnType(Lazy, loc, fnType, ascribedTypeArgs), + args, + ); + return { + returnType: result.returnType, + typeArgMap: new Map( + zip(fnType.typeParams.order, args).map(([name, [, type]]) => [ + name.text, + type, + ]), + ), + }; +} +const ENoFunction = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`No such function`), Ast.TECode(loc), +); + +function substFnType( + Lazy: Ast.ThunkBuilder, + fnLoc: Ast.Loc, + { + typeParams, + params, + returnType, + }: Ast.CTFunction | Ast.CTMethod, + args: readonly Ast.CType[], +) { + const order: Ast.CParameter[] = []; + for (const [index, param] of params.order.entries()) { + order.push( + Ast.CParameter( + param.name, + Lazy({ + callback: function* () { + return substituteTypeArgs( + yield* param.type(), + typeParams, + args, + ); + }, + context: [ + Ast.TEText( + `substituting into parameter ${getParamName(param.name, index)}`, + ), + ], + loc: param.loc, + recover: Ast.CTRecover(), + }), + param.loc, + ), + ); + } + return Ast.CTFunction( + emptyTypeParams, + Ast.CParameters(order, params.set), + Lazy({ + callback: function* () { + return substituteTypeArgs( + yield* returnType(), + typeParams, + args, + ); + }, + context: [Ast.TEText(`substituting into return type`)], + loc: fnLoc, + recover: Ast.CTRecover(), + }), + ); +} + +export type MethodCallResult = CallResult & { + readonly mutates: boolean; +}; + +export function* lookupMethod( + Lazy: Ast.ThunkBuilder, + selfType: Ast.CType, + method: Ast.Id, + args: readonly (readonly [Ast.Loc, Ast.CType])[], + typeDecls: ReadonlyMap>, + extensions: ReadonlyMap[]>>, +): Ast.Log { + if (selfType.kind === "recover") { + return { returnType: Ast.CTRecover(), typeArgMap: new Map(), mutates: false }; + } + if (selfType.kind === "TypeAlias") { + if (selfType.type.kind === "NotDealiased") { + return throwInternal("Calling method on non-dealiased type"); + } + + return yield* lookupMethod( + Lazy, + selfType, + method, + args, + typeDecls, + extensions, + ); + } + + if (selfType.kind !== "type_ref") { + return yield* lookupExts(Lazy, selfType, method, args, extensions); + } + + const selfDecl = typeDecls.get(selfType.name.text); + if (!selfDecl) { + yield ENoMethod(method.loc); + return { returnType: Ast.CTRecover(), typeArgMap: new Map(), mutates: false }; + } + + if (selfDecl.decl.kind === "struct" || selfDecl.decl.kind === "message") { + const builtinMap = + selfDecl.decl.kind === "struct" ? structBuiltin : messageBuiltin; + const builtin = builtinMap.get(method.text); + if (builtin) { + return { + ...yield* checkFnCall(method.loc, builtin, args), + mutates: false, + }; + } + return yield* lookupExts(Lazy, selfType, method, args, extensions); + } + + if (selfDecl.decl.kind === "contract" || selfDecl.decl.kind === "trait") { + const content = yield* selfDecl.decl.content(); + const met = content.methods.get(method.text); + if (!met) { + yield ENoMethod(method.loc); + return { returnType: Ast.CTRecover(), typeArgMap: new Map(), mutates: false }; + } + return { + ...yield* checkFnCall(method.loc, met.decl.type, args), + mutates: met.decl.type.mutates, + }; + } + + yield ENoMethod(method.loc); + return { returnType: Ast.CTRecover(), typeArgMap: new Map(), mutates: false }; +} + +function* lookupExts( + Lazy: Ast.ThunkBuilder, + selfType: Ast.CType, + method: Ast.Id, + args: readonly (readonly [Ast.Loc, Ast.CType])[], + extensions: ReadonlyMap[]>>, +): Ast.Log { + const lazyExts = extensions.get(method.text); + if (!lazyExts) { + yield ENoMethod(method.loc); + return { returnType: Ast.CTRecover(), typeArgMap: new Map(), mutates: false }; + } + const exts = yield* lazyExts(); + const grounds: [Ast.CTMethod, Ast.TypeArgs][] = []; + const withVars: [Ast.CTMethod, Ast.TypeArgs][] = []; + for (const { decl } of exts) { + const subst = typeParamsToSubst(decl.type.typeParams); + const result = assignTypeAux(decl.type.self, selfType, subst, true); + if (result.kind !== "success") { + continue; + } + const res = substToTypeArgMapAux(subst); + if (!res.ok) { + continue; + } + const into = decl.type.self.ground ? grounds : withVars; + into.push([decl.type, res.args]); + } + if (grounds.length > 1 || withVars.length > 1) { + return throwInternal("Overlapping methods were allowed"); + } + const [ground] = grounds; + const [withVar] = withVars; + const either = ground || withVar; + if (!either) { + yield ENoMethod(method.loc); + return { returnType: Ast.CTRecover(), typeArgMap: new Map(), mutates: false }; + } + const [methodType, typeArgs] = either; + const result = yield* checkFnCall( + method.loc, + substFnType( + Lazy, + method.loc, + methodType, + typeArgsToParams(typeArgs, methodType.typeParams), + ), + args, + ); + return { + returnType: result.returnType, + typeArgMap: typeArgs, + mutates: methodType.mutates, + }; +} + +function typeArgsToParams(args: Ast.TypeArgs, params: Ast.CTypeParams) { + const result: Ast.CType[] = []; + for (const name of params.order) { + const arg = args.get(name.text); + if (!arg) { + return throwInternal("Lost type arguments"); + } + result.push(arg); + } + return result; +} + +const ENoMethod = (loc: Ast.Loc) => Ast.TcError( + loc, + Ast.TEText(`No such method`), Ast.TECode(loc), +); + +export function* assignMethodType( + prev: Ast.CTMethod, + next: Ast.CTMethod, + prevVia: Ast.ViaMember, + nextVia: Ast.ViaMember, +): Ast.Log { + const result = assignTypeAux( + yield* prev.returnType(), + yield* next.returnType(), + new Map(), + true, + ); + if (result.kind === "failure") { + yield EMismatchReturn(result.tree, prevVia.defLoc, nextVia.defLoc); + return undefined; + } + const prevArity = prev.params.order.length; + const nextArity = next.params.order.length; + + for (const [index, [prevParam, nextParam]] of zip( + prev.params.order, + next.params.order, + ).entries()) { + const result = assignTypeAux( + yield* prevParam.type(), + yield* nextParam.type(), + new Map(), + true, + ); + if (result.kind === "failure") { + yield EMismatchParam( + getParamName(nextParam.name, index), + result.tree, + prevVia.defLoc, + nextVia.defLoc, + ); + } + } + + if (prevArity !== nextArity) { + yield EFnArity("Method", prevArity, nextArity, nextVia.defLoc); + } +} + +const EMismatchReturn = ( + tree: Ast.MatchTree, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText(`Return type doesn't match with inherited method`), + Ast.TEMismatch(tree), + Ast.TEText(`Inherited from:`), + Ast.TECode(prev), + Ast.TEText(`Override at:`), + Ast.TECode(next), +); + +const EMismatchParam = ( + name: string, + tree: Ast.MatchTree, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText( + `Type of parameter ${name} doesn't match with inherited method`, + ), + Ast.TEMismatch(tree), + Ast.TEText(`Inherited from:`), + Ast.TECode(prev), + Ast.TEText(`Override at:`), + Ast.TECode(next), +); diff --git a/src/next/types/typecheck.ts b/src/next/types/typecheck.ts new file mode 100644 index 0000000000..a25323d71f --- /dev/null +++ b/src/next/types/typecheck.ts @@ -0,0 +1,70 @@ +/* eslint-disable @typescript-eslint/consistent-type-imports */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable require-yield */ +// import { logDeep } from "@/utils/log-deep.build"; +import * as Ast from "@/next/ast"; +import { memo } from "@/utils/tricks"; +import type { + ResolvedImport, + TactImport, + TactSource, +} from "@/next/imports/source"; +import { decodeTypeDecls } from "@/next/types/typedecl"; +import { decodeFunctions } from "@/next/types/functions"; +import { decodeConstants } from "@/next/types/constants"; +import { decodeExtensions } from "@/next/types/extensions"; + +export const typecheck = (root: TactSource): [Ast.CSource, Ast.TcError[]] => { + const allErrors: Ast.TcError[] = []; + + const recur = memo((source: TactSource): Ast.CSource => { + const [value, errors] = Ast.runLog( + tcSource( + // leave only imports of .tact + onlyTactImports(source.imports).map((importedBy) => ({ + globals: recur(importedBy.source), + importedBy, + })), + source, + ), + ); + // `recur` is called only once on every source + // this ensures errors from every source get counted + // only once + allErrors.push(...errors); + return value; + }); + + return [recur(root), allErrors]; +}; + +const onlyTactImports = ( + imports: readonly ResolvedImport[], +): readonly TactImport[] => { + // typescript narrowing doesn't properly apply to filter, + // so we need this helper + const result: TactImport[] = []; + for (const imp of imports) { + if (imp.kind === "tact") { + result.push(imp); + } + } + return result; +}; + +function* tcSource( + // list of import+source pairs for every of file's imports + imported: readonly Ast.SourceCheckResult[], + // source for current file + source: TactSource, +): Ast.Log { + const Lazy = Ast.thunkBuilder; + const scopeRef = () => scope; + const scope: Ast.CSource = { + typeDecls: yield* decodeTypeDecls(Lazy, imported, source, scopeRef), + functions: yield* decodeFunctions(Lazy, imported, source, scopeRef), + constants: yield* decodeConstants(Lazy, imported, source, scopeRef), + extensions: decodeExtensions(Lazy, imported, source, scopeRef), + }; + return scope; +} diff --git a/src/next/types/typedecl.ts b/src/next/types/typedecl.ts new file mode 100644 index 0000000000..fc2f8520d0 --- /dev/null +++ b/src/next/types/typedecl.ts @@ -0,0 +1,101 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import type { TactSource } from "@/next/imports/source"; +import { builtinTypes } from "@/next/types/builtins"; +import { decodeAlias } from "@/next/types/alias"; +import { decodeContract } from "@/next/types/contract"; +import { decodeTrait } from "@/next/types/trait"; +import { decodeStruct } from "@/next/types/struct"; +import { decodeMessage } from "@/next/types/message"; +import { decodeUnion } from "@/next/types/union"; + +const errorKind = "type"; + +export function* decodeTypeDecls( + Lazy: Ast.ThunkBuilder, + imported: readonly Ast.SourceCheckResult[], + source: TactSource, + scopeRef: () => Ast.CSource, +): Ast.Log>> { + const importedSigs = imported.map( + ({ globals, importedBy }) => + new Map( + globals.typeDecls + .entries() + .map(([name, s]) => [ + name, + Ast.Decl(s.decl, Ast.ViaImport(importedBy, s.via)), + ]), + ), + ); + + const localSigs = yield* Ast.mapLog(source.items.types, function* (decl) { + const via = Ast.ViaOrigin(decl.loc, source); + return new Map([ + [ + decl.name.text, + Ast.Decl(yield* decodeTypeDecl(Lazy, decl, scopeRef), via), + ], + ]); + }); + + const prev: Map> = new Map(); + for (const next of [...importedSigs, ...localSigs]) { + for (const [name, nextItem] of next) { + const prevItem = prev.get(name); + // defined in compiler + if (builtinTypes.has(name)) { + yield Ast.ERedefine( + errorKind, + name, + Ast.ViaBuiltin(), + nextItem.via, + ); + continue; + } + // not defined yet; define it now + if (typeof prevItem === "undefined") { + prev.set(name, nextItem); + continue; + } + // already defined, and it's not a diamond situation + if (prevItem.via.source !== nextItem.via.source) { + yield Ast.ERedefine( + errorKind, + name, + prevItem.via, + nextItem.via, + ); + } + } + } + return prev; +} + +function* decodeTypeDecl( + Lazy: Ast.ThunkBuilder, + decl: Ast.TypeDecl, + scopeRef: () => Ast.CSource, +): Ast.Log { + switch (decl.kind) { + case "alias_decl": { + return yield* decodeAlias(Lazy, decl, scopeRef); + } + case "contract": { + return yield* decodeContract(Lazy, decl, scopeRef); + } + case "trait": { + return yield* decodeTrait(Lazy, decl, scopeRef); + } + case "struct_decl": { + return yield* decodeStruct(Lazy, decl, scopeRef); + } + case "message_decl": { + return yield* decodeMessage(Lazy, decl, scopeRef); + } + case "union_decl": { + return yield* decodeUnion(Lazy, decl, scopeRef); + } + } +} diff --git a/src/next/types/union.ts b/src/next/types/union.ts new file mode 100644 index 0000000000..0655813347 --- /dev/null +++ b/src/next/types/union.ts @@ -0,0 +1,90 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; +import { decodeInitializerLazy } from "@/next/types/struct-fields"; +import { decodeTypeLazy } from "@/next/types/type"; +import { decodeTypeParams } from "@/next/types/type-params"; + +type Cons = { + readonly fields: ReadonlyMap; + readonly loc: Ast.Loc; +}; + +export function* decodeUnion( + Lazy: Ast.ThunkBuilder, + union: Ast.UnionDecl, + scopeRef: () => Ast.CSource, +): Ast.Log { + const typeParams = yield* decodeTypeParams(union.typeParams); + + const cases: Map = new Map(); + for (const cons of union.cases) { + const caseName = cons.name.text; + const prevCons = cases.get(caseName); + if (prevCons) { + yield EDuplicateCons(caseName, prevCons.loc, cons.name.loc); + continue; + } + const fields: Map = new Map(); + for (const field of cons.fields) { + const fieldName = field.name.text; + const prevField = fields.get(fieldName); + if (prevField) { + const [, prevFieldLoc] = prevField; + yield EDuplicateField(fieldName, prevFieldLoc, field.name.loc); + } + const ascribedType = decodeTypeLazy( + Lazy, + typeParams, + field.type, + scopeRef, + ); + + const lazyExpr = decodeInitializerLazy( + Lazy, + field.loc, + typeParams, + ascribedType, + field.initializer, + undefined, + scopeRef, + ); + + const decoded = Ast.CField(ascribedType, lazyExpr); + fields.set(fieldName, [decoded, field.name.loc]); + } + cases.set(caseName, { + fields: new Map([...fields].map(([name, [type]]) => [name, type])), + loc: cons.name.loc, + }); + } + + const map = new Map([...cases].map(([name, { fields }]) => [name, fields])); + return Ast.CUnion(typeParams, map); +} + +const EDuplicateCons = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText(`Duplicate union case "${name}"`), + Ast.TEText(`Defined at:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); + +const EDuplicateField = ( + name: string, + prev: Ast.Loc, + next: Ast.Loc, +) => Ast.TcError( + next, + Ast.TEText(`Duplicate field "${name}"`), + Ast.TEText(`Defined at:`), + Ast.TECode(next), + Ast.TEText(`Previously defined at:`), + Ast.TECode(prev), +); diff --git a/src/next/types/value.ts b/src/next/types/value.ts new file mode 100644 index 0000000000..98330ee6bf --- /dev/null +++ b/src/next/types/value.ts @@ -0,0 +1,17 @@ +/* eslint-disable require-yield */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import * as Ast from "@/next/ast"; + +export function convertValueToExpr(node: Ast.Value): Ast.CExpr { + switch (node.kind) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + case "number": { + return Ast.DNumber( + "10", + node.value, + Ast.TBasic(Ast.TInt(Ast.IFInt("signed", 257, node.loc), node.loc), node.loc), + node.loc, + ); + } + } +} diff --git a/src/stdlib/stdlib.ts b/src/stdlib/stdlib.ts index f1497f29df..7285b8e407 100644 --- a/src/stdlib/stdlib.ts +++ b/src/stdlib/stdlib.ts @@ -197,244 +197,237 @@ files["libs/stoppable.tact"] = "IHN0b3BwZWQuCiAgICByZWNlaXZlKCJSZXN1bWUiKSB7CiAgICAgICAgc2VsZi5yZXF1aXJlT3duZXIoKTsKICAgICAgICBzZWxmLnJlcXVpcmVTdG9wcGVkKCk7CiAg" + "ICAgICAgc2VsZi5zdG9wcGVkID0gZmFsc2U7CiAgICAgICAgc2VsZi5yZXBseSgiUmVzdW1lZCIuYXNDb21tZW50KCkpOwogICAgfQp9Cg=="; files["std/internal/address.tact"] = - "Ly8vIEV4dGVuc2lvbiBmdW5jdGlvbiBmb3IgdGhlIGBTbGljZWAgdHlwZS4gQXZhaWxhYmxlIHNpbmNlIFRhY3QgMS42LjAuCi8vLwovLy8gQ2FzdHMgdGhlIGBTbGlj" + - "ZWAgdG8gYW4gYEFkZHJlc3NgIGluIGEgZ2l2ZW4gYGNoYWluYCBJRCBhbmQgcmV0dXJucyBpdC4gVGhlIGludmVyc2Ugb2YgYEFkZHJlc3MuYXNTbGljZSgpYCBhbmQg" + - "YSBzYWZlIGJ1dCBtb3JlIGdhcy1leHBlbnNpdmUgdmVyc2lvbiBvZiBgU2xpY2UuYXNBZGRyZXNzVW5zYWZlKClgLgovLy8KLy8vIGBgYHRhY3QKLy8vIGZ1biBleGFt" + - "cGxlKCkgewovLy8gICAgIGxldCBhOiBBZGRyZXNzID0gbXlBZGRyZXNzKCk7IC8vIGxldCdzIGFzc3VtZSB3ZSdyZSBpbiBhIGJhc2VjaGFpbgovLy8gICAgIGxldCBh" + - "MjogQWRkcmVzcyA9IGEuYXNTbGljZSgpLmFzQWRkcmVzcygwKTsgLy8gc28gdGhlIGNoYWluIElEIGlzIDAKLy8vCi8vLyAgICAgYSA9PSBhMjsgLy8gdHJ1ZQovLy8g" + - "fQovLy8gYGBgCi8vLwovLy8gIyMjIyBFeGl0IGNvZGVzCi8vLwovLy8gKiAxMzY6IFtJbnZhbGlkIHN0YW5kYXJ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mFsYW5jZWAgbW9kZQogICAgLy8vICAgICBvdmVycmlkZSBjb25zdCBz" + - "dG9yYWdlUmVzZXJ2ZTogSW50ID0gdG9uKCIwLjEiKTsKICAgIC8vLyB9CiAgICAvLy8gYGBgCiAgICAvLy8KICAgIC8vLyBTZWU6IGh0dHBzOi8vZG9jcy50YWN0LWxh" + - "bmcub3JnL3JlZi9jb3JlLWJhc2Ujc2VsZi1mb3J3YXJkCiAgICAvLy8KICAgIHZpcnR1YWwgY29uc3Qgc3RvcmFnZVJlc2VydmU6IEludCA9IDA7CgogICAgLy8vIFNl" + - "bmRzIGEgYm91bmNlYWJsZSBtZXNzYWdlIGJhY2sgdG8gdGhlIHNlbmRlciBvZiB0aGUgY3VycmVudCBtZXNzYWdlLgogICAgLy8vIEEgc2ltaWxhciBidXQgbW9yZSBn" + - "YXMtZWZmaWNpZW50IHZlcnNpb24gb2YgY2FsbGluZyB0aGUgYHNlbGYuZm9yd2FyZCgpYAogICAgLy8vIGZ1bmN0aW9uIHdpdGggdGhlIGZvbGxvd2luZyBhcmd1bWVu" + - "dHM6CiAgICAvLy8KICAgIC8vLyBgYGB0YWN0CiAgICAvLy8gc2VsZi5mb3J3YXJkKHNlbmRlcigpLCBib2R5LCB0cnVlLCBudWxsKTsKICAgIC8vLyAvLyAgICAgICAg" + - "ICAg4oaRICAgICAgICAg4oaRICAgICDihpEgICAgIOKGkQogICAgLy8vIC8vICAgICAgICAgICB8ICAgICAgICAgfCAgICAgfCAgICAgaW5pdDogU3RhdGVJbml0Pwog" + - "ICAgLy8vIC8vICAgICAgICAgICB8ICAgICAgICAgfCAgICAgYm91bmNlOiBCb29sCiAgICAvLy8gLy8gICAgICAgICAgIHwgICAgICAgICBib2R5OiBDZWxsPwogICAg" + - "Ly8vIC8vICAgICAgICAgICB0bzogQWRkcmVzcwogICAgLy8vIGBgYAogICAgLy8vCiAgICAvLy8gU2VlOiBodHRwczovL2RvY3MudGFjdC1sYW5nLm9yZy9yZWYvY29y" + - "ZS1iYXNlI3NlbGYtZm9yd2FyZAogICAgLy8vCiAgICB2aXJ0dWFsIGlubGluZSBmdW4gcmVwbHkoYm9keTogQ2VsbD8pIHsKICAgICAgICBsZXQgdG86IEFkZHJlc3Mg" + - "PSBzZW5kZXIoKTsKICAgICAgICBsZXQgYm91bmNlOiBCb29sID0gdHJ1ZTsKICAgICAgICBpZiAoc2VsZi5zdG9yYWdlUmVzZXJ2ZSA+IDApIHsgLy8gT3B0aW1pemVk" + - "IGluIGNvbXBpbGUtdGltZQogICAgICAgICAgICBsZXQgYmFsYW5jZTogSW50ID0gbXlCYWxhbmNlKCk7CiAgICAgICAgICAgIGxldCBiYWxhbmNlQmVmb3JlTWVzc2Fn" + - "ZTogSW50ID0gYmFsYW5jZSAtIGNvbnRleHQoKS52YWx1ZTsKICAgICAgICAgICAgaWYgKGJhbGFuY2VCZWZvcmVNZXNzYWdlIDwgc2VsZi5zdG9yYWdlUmVzZXJ2ZSkg" + - "ewogICAgICAgICAgICAgICAgbmF0aXZlUmVzZXJ2ZShzZWxmLnN0b3JhZ2VSZXNlcnZlLCBSZXNlcnZlRXhhY3QpOwogICAgICAgICAgICAgICAgbWVzc2FnZShNZXNz" + - "YWdlUGFyYW1ldGVycyB7CiAgICAgICAgICAgICAgICAgICAgYm91bmNlLAogICAgICAgICAgICAgICAgICAgIHRvLAogICAgICAgICAgICAgICAgICAgIHZhbHVlOiAw" + - "LAogICAgICAgICAgICAgICAgICAgIG1vZGU6IFNlbmRSZW1haW5pbmdCYWxhbmNlIHwgU2VuZElnbm9yZUVycm9ycywKICAgICAgICAgICAgICAgICAgICBib2R5LAog" + - "ICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEp1c3Qgc2VuZCB3aXRoIHJl" + - "bWFpbmluZyBiYWxhbmNlCiAgICAgICAgbWVzc2FnZShNZXNzYWdlUGFyYW1ldGVycyB7CiAgICAgICAgICAgIGJvdW5jZSwKICAgICAgICAgICAgdG8sCiAgICAgICAg" + - "ICAgIHZhbHVlOiAwLAogICAgICAgICAgICBtb2RlOiBTZW5kUmVtYWluaW5nVmFsdWUgfCBTZW5kSWdub3JlRXJyb3JzLAogICAgICAgICAgICBib2R5LAogICAgICAg" + - "IH0pOwogICAgfQoKICAgIC8vLyBTZW5kcyBhIG5vbi1ib3VuY2VhYmxlIG1lc3NhZ2UgYmFjayB0byB0aGUgc2VuZGVyIG9mIHRoZSBjdXJyZW50IG1lc3NhZ2UuCiAg" + - "ICAvLy8gQSBzaW1pbGFyIGJ1dCBtb3JlIGdhcy1lZmZpY2llbnQgdmVyc2lvbiBvZiBjYWxsaW5nIHRoZSBgc2VsZi5mb3J3YXJkKClgCiAgICAvLy8gZnVuY3Rpb24g" + - "d2l0aCB0aGUgZm9sbG93aW5nIGFyZ3VtZW50czoKICAgIC8vLwogICAgLy8vIGBgYHRhY3QKICAgIC8vLyBzZWxmLmZvcndhcmQoc2VuZGVyKCksIGJvZHksIGZhbHNl" + - "LCBudWxsKTsKICAgIC8vLyAvLyAgICAgICAgICAg4oaRICAgICAgICAg4oaRICAgICDihpEgICAgIOKGkQogICAgLy8vIC8vICAgICAgICAgICB8ICAgICAgICAgfCAg" + - "ICAgfCAgICAgaW5pdDogU3RhdGVJbml0PwogICAgLy8vIC8vICAgICAgICAgICB8ICAgICAgICAgfCAgICAgYm91bmNlOiBCb29sCiAgICAvLy8gLy8gICAgICAgICAg" + - "IHwgICAgICAgICBib2R5OiBDZWxsPwogICAgLy8vIC8vICAgICAgICAgICB0bzogQWRkcmVzcwogICAgLy8vIGBgYAogICAgLy8vCiAgICAvLy8gU2VlOiBodHRwczov" + - "L2RvY3MudGFjdC1sYW5nLm9yZy9yZWYvY29yZS1iYXNlI3NlbGYtZm9yd2FyZAogICAgLy8vCiAgICB2aXJ0dWFsIGlubGluZSBmdW4gbm90aWZ5KGJvZHk6IENlbGw/" + - "KSB7CiAgICAgICAgbGV0IHRvOiBBZGRyZXNzID0gc2VuZGVyKCk7CiAgICAgICAgbGV0IGJvdW5jZTogQm9vbCA9IGZhbHNlOwogICAgICAgIGlmIChzZWxmLnN0b3Jh" + - "Z2VSZXNlcnZlID4gMCkgeyAvLyBPcHRpbWl6ZWQgaW4gY29tcGlsZS10aW1lCiAgICAgICAgICAgIGxldCBiYWxhbmNlOiBJbnQgPSBteUJhbGFuY2UoKTsKICAgICAg" + - "ICAgICAgbGV0IGJhbGFuY2VCZWZvcmVNZXNzYWdlOiBJbnQgPSBiYWxhbmNlIC0gY29udGV4dCgpLnZhbHVlOwogICAgICAgICAgICBpZiAoYmFsYW5jZUJlZm9yZU1l" + - "c3NhZ2UgPCBzZWxmLnN0b3JhZ2VSZXNlcnZlKSB7CiAgICAgICAgICAgICAgICBuYXRpdmVSZXNlcnZlKHNlbGYuc3RvcmFnZVJlc2VydmUsIFJlc2VydmVFeGFjdCk7" + - "CiAgICAgICAgICAgICAgICBtZXNzYWdlKE1lc3NhZ2VQYXJhbWV0ZXJzIHsKICAgICAgICAgICAgICAgICAgICBib3VuY2UsCiAgICAgICAgICAgICAgICAgICAgdG8s" + - "CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IDAsCiAgICAgICAgICAgICAgICAgICAgbW9kZTogU2VuZFJlbWFpbmluZ0JhbGFuY2UgfCBTZW5kSWdub3JlRXJyb3Jz" + - "LAogICAgICAgICAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgIH0K" + - "CiAgICAgICAgLy8gSnVzdCBzZW5kIHdpdGggcmVtYWluaW5nIGJhbGFuY2UKICAgICAgICBtZXNzYWdlKE1lc3NhZ2VQYXJhbWV0ZXJzIHsKICAgICAgICAgICAgYm91" + - "bmNlLAogICAgICAgICAgICB0bywKICAgICAgICAgICAgdmFsdWU6IDAsCiAgICAgICAgICAgIG1vZGU6IFNlbmRSZW1haW5p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WN0" + - "KTsKICAgICAgICAgICAgICAgICAgICBtZXNzYWdlKE1lc3NhZ2VQYXJhbWV0ZXJzIHsKICAgICAgICAgICAgICAgICAgICAgICAgYm91bmNlLAogICAgICAgICAgICAg" + - "ICAgICAgICAgICB0bywKICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIG1vZGU6IFNlbmRSZW1haW5pbmdCYWxh" + - "bmNlIHwgU2VuZElnbm9yZUVycm9ycywKICAgICAgICAgICAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAg" + - "ICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIC8vIEp1c3Qgc2VuZCB3aXRoIHJlbWFpbmluZyBiYWxhbmNlCiAgICAg" + - "ICAgICAgIG1lc3NhZ2UoTWVzc2FnZVBhcmFtZXRlcnMgewogICAgICAgICAgICAgICAgYm91bmNlLAogICAgICAgICAgICAgICAgdG8sCiAgICAgICAgICAgICAgICB2" + - "YWx1ZTogMCwKICAgICAgICAgICAgICAgIG1vZGU6IFNlbmRSZW1haW5pbmdWYWx1ZSB8IFNlbmRJZ25vcmVFcnJvcnMsCiAgICAgICAgICAgICAgICBib2R5LAogICAg" + - "ICAgICAgICB9KTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KCiAgICAgICAgLy8gTG9jayBzdG9yYWdlIGlmIG5lZWRlZAogICAgICAgIGlmIChzZWxmLnN0" + - "b3JhZ2VSZXNlcnZlID4gMCkgeyAvLyBPcHRpbWl6ZWQgaW4gY29tcGlsZS10aW1lCiAgICAgICAgICAgIGxldCBjdHg6IENvbnRleHQgPSBjb250ZXh0KCk7CiAgICAg" + - "ICAgICAgIGxldCBiYWxhbmNlOiBJbnQgPSBteUJhbGFuY2UoKTsKICAgICAgICAgICAgbGV0IGJhbGFuY2VCZWZvcmVNZXNzYWdlOiBJbnQgPSBiYWxhbmNlIC0gY3R4" + - "LnZhbHVlOwogICAgICAgICAgICBpZiAoYmFsYW5jZUJlZm9yZU1lc3NhZ2UgPCBzZWxmLnN0b3JhZ2VSZXNlcnZlKSB7CiAgICAgICAgICAgICAgICBuYXRpdmVSZXNl" + - "cnZlKHNlbGYuc3RvcmFnZVJlc2VydmUsIFJlc2VydmVFeGFjdCk7CiAgICAgICAgICAgICAgICBzZW5kKFNlbmRQYXJhbWV0ZXJzIHsKICAgICAgICAgICAgICAgICAg" + - "ICB0bywKICAgICAgICAgICAgICAgICAgICBtb2RlOiBTZW5kUmVtYWluaW5nQmFsYW5jZSB8IFNlbmRJZ25vcmVFcnJvcnMsCiAgICAgICAgICAgICAgICAgICAgYm9k" + - "eSwKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMCwKICAgICAgICAgICAgICAgICAgICBib3VuY2UsCiAgICAgICAgICAgICAgICAgICAgY29kZTogaW5pdCEhLmNv" + - "ZGUsCiAgICAgICAgICAgICAgICAgICAgZGF0YTogaW5pdCEhLmRhdGEsCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAg" + - "ICAgfQogICAgICAgIH0KCiAgICAgICAgLy8gSnVzdCBzZW5kIHdpdGggcmVtYWluaW5nIGJhbGFuY2UKICAgICAgICBzZW5kKFNlbmRQYXJhbWV0ZXJzIHsKICAgICAg" + - "ICAgICAgYm91bmNlLAogICAgICAgICAgICB0bywKICAgICAgICAgICAgdmFsdWU6IDAsCiAgICAgICAgICAgIG1vZGU6IFNlbmRSZW1haW5pbmdWYWx1ZSB8IFNlbmRJ" + - "Z25vcmVFcnJvcnMsCiAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgIGNvZGU6IGluaXQhIS5jb2RlLAogICAgICAgICAgICBkYXRhOiBpbml0ISEuZGF0YSwKICAg" + - "ICAgICB9KTsKICAgIH0KfQo="; + "aW1wb3J0ICIuL2NvbnRleHQiOwppbXBvcnQ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ICAgICAgICAgYm9keTogQ2VsbD8KICAgIC8vLyAvLyAgICAgICAgICAg" + + "dG86IEFkZHJlc3MKICAgIC8vLyBgYGAKICAgIC8vLwogICAgLy8vIFNlZTogaHR0cHM6Ly9kb2NzLnRhY3QtbGFuZy5vcmcvcmVmL2NvcmUtYmFzZSNzZWxmLWZvcndh" + + "cmQKICAgIC8vLwogICAgdmlydHVhbCBpbmxpbmUgZnVuIHJlcGx5KGJvZHk6IENlbGw/KSB7CiAgICAgICAgbGV0IHRvOiBBZGRyZXNzID0gc2VuZGVyKCk7CiAgICAg" + + "ICAgbGV0IGJvdW5jZTogQm9vbCA9IHRydWU7CiAgICAgICAgaWYgKHNlbGYuc3RvcmFnZVJlc2VydmUgPiAwKSB7IC8vIE9wdGltaXplZCBpbiBjb21waWxlLXRpbWUK" + + "ICAgICAgICAgICAgbGV0IGJhbGFuY2U6IEludCA9IG15QmFsYW5jZSgpOwogICAgICAgICAgICBsZXQgYmFsYW5jZUJlZm9yZU1lc3NhZ2U6IEludCA9IGJhbGFuY2Ug" + + "LSBjb250ZXh0KCkudmFsdWU7CiAgICAgICAgICAgIGlmIChiYWxhbmNlQmVmb3JlTWVzc2FnZSA8IHNlbGYuc3RvcmFnZVJlc2VydmUpIHsKICAgICAgICAgICAgICAg" + + "IG5hdGl2ZVJlc2VydmUoc2VsZi5zdG9yYWdlUmVzZXJ2ZSwgUmVzZXJ2ZUV4YWN0KTsKICAgICAgICAgICAgICAgIG1lc3NhZ2UoTWVzc2FnZVBhcmFtZXRlcnMgewog" + + "ICAgICAgICAgICAgICAgICAgIGJvdW5jZSwKICAgICAgICAgICAgICAgICAgICB0bywKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMCwKICAgICAgICAgICAgICAg" + + "ICAgICBtb2RlOiBTZW5kUmVtYWluaW5nQmFsYW5jZSB8IFNlbmRJZ25vcmVFcnJvcnMsCiAgICAgICAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgICAgIH0p" + + "OwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAvLyBKdXN0IHNlbmQgd2l0aCByZW1haW5pbmcgYmFsYW5jZQog" + + "ICAgICAgIG1lc3NhZ2UoTWVzc2FnZVBhcmFtZXRlcnMgewogICAgICAgICAgICBib3VuY2UsCiAgICAgICAgICAgIHRvLAogICAgICAgICAgICB2YWx1ZTogMCwKICAg" + + "ICAgICAgICAgbW9kZTogU2VuZFJlbWFpbmluZ1ZhbHVlIHwgU2VuZElnbm9yZUVycm9ycywKICAgICAgICAgICAgYm9keSwKICAgICAgICB9KTsKICAgIH0KCiAgICAv" + + "Ly8gU2VuZHMgYSBub24tYm91bmNlYWJsZSBtZXNzYWdlIGJhY2sgdG8gdGhlIHNlbmRlciBvZiB0aGUgY3VycmVudCBtZXNzYWdlLgogICAgLy8vIEEgc2ltaWxhciBi" + + "dXQgbW9yZSBnYXMtZWZmaWNpZW50IHZlcnNpb24gb2YgY2FsbGluZyB0aGUgYHNlbGYuZm9yd2FyZCgpYAogICAgLy8vIGZ1bmN0aW9uIHdpdGggdGhlIGZvbGxvd2lu" + + "ZyBhcmd1bWVudHM6CiAgICAvLy8KICAgIC8vLyBgYGB0YWN0CiAgICAvLy8gc2VsZi5mb3J3YXJkKHNlbmRlcigpLCBib2R5LCBmYWxzZSwgbnVsbCk7CiAgICAvLy8g" + + "Ly8gICAgICAgICAgIOKGkSAgICAgICAgIOKGkSAgICAg4oaRICAgICDihpEKICAgIC8vLyAvLyAgICAgICAgICAgfCAgICAgICAgIHwgICAgIHwgICAgIGluaXQ6IFN0" + + "YXRlSW5pdD8KICAgIC8vLyAvLyAgICAgICAgICAgfCAgICAgICAgIHwgICAgIGJvdW5jZTogQm9vbAogICAgLy8vIC8vICAgICAgICAgICB8ICAgICAgICAgYm9keTog" + + "Q2VsbD8KICAgIC8vLyAvLyAgICAgICAgICAgdG86IEFkZHJlc3MKICAgIC8vLyBgYGAKICAgIC8vLwogICAgLy8vIFNlZTogaHR0cHM6Ly9kb2NzLnRhY3QtbGFuZy5v" + + "cmcvcmVmL2NvcmUtYmFzZSNzZWxmLWZvcndhcmQKICAgIC8vLwogICAgdmlydHVhbCBpbmxpbmUgZnVuIG5vdGlmeShib2R5OiBDZWxsPykgewogICAgICAgIGxldCB0" + + "bzogQWRkcmVzcyA9IHNlbmRlcigpOwogICAgICAgIGxldCBib3VuY2U6IEJvb2wgPSBmYWxzZTsKICAgICAgICBpZiAoc2VsZi5zdG9yYWdlUmVzZXJ2ZSA+IDApIHsg" + + "Ly8gT3B0aW1pemVkIGluIGNvbXBpbGUtdGltZQogICAgICAgICAgICBsZXQgYmFsYW5jZTogSW50ID0gbXlCYWxhbmNlKCk7CiAgICAgICAgICAgIGxldCBiYWxhbmNl" + + "QmVmb3JlTWVzc2FnZTogSW50ID0gYmFsYW5jZSAtIGNvbnRleHQoKS52YWx1ZTsKICAgICAgICAgICAgaWYgKGJhbGFuY2VCZWZvcmVNZXNzYWdlIDwgc2VsZi5zdG9y" + + "YWdlUmVzZXJ2ZSkgewogICAgICAgICAgICAgICAgbmF0aXZlUmVzZXJ2ZShzZWxmLnN0b3JhZ2VSZXNlcnZlLCBSZXNlcnZlRXhhY3QpOwogICAgICAgICAgICAgICAg" + + "bWVzc2FnZShNZXNzYWdlUGFyYW1ldGVycyB7CiAgICAgICAgICAgICAgICAgICAgYm91bmNlLAogICAgICAgICAgICAgICAgICAgIHRvLAogICAgICAgICAgICAgICAg" + + "ICAgIHZhbHVlOiAwLAogICAgICAgICAgICAgICAgICAgIG1vZGU6IFNlbmRSZW1haW5pbmdCYWxhbmNlIHwgU2VuZElnbm9yZUVycm9ycywKICAgICAgICAgICAgICAg" + + "ICAgICBib2R5LAogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEp1c3Qg" + + "c2VuZCB3aXRoIHJlbWFpbmluZyBiYWxh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mb3JlTWVzc2FnZSA8IHNlbGYuc3RvcmFn" + + "ZVJlc2VydmUpIHsKICAgICAgICAgICAgICAgICAgICBuYXRpdmVSZXNlcnZlKHNlbGYuc3RvcmFnZVJlc2VydmUsIFJlc2VydmVFeGFjdCk7CiAgICAgICAgICAgICAg" + + "ICAgICAgbWVzc2FnZShNZXNzYWdlUGFyYW1ldGVycyB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5jZSwKICAgICAgICAgICAgICAgICAgICAgICAgdG8sCiAg" + + "ICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwLAogICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiBTZW5kUmVtYWluaW5nQmFsYW5jZSB8IFNlbmRJZ25vcmVF" + + "cnJvcnMsCiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAg" + + "ICAgICAgICAgfQogICAgICAgICAgICB9CgogICAgICAgICAgICAvLyBKdXN0IHNlbmQgd2l0aCByZW1haW5pbmcgYmFsYW5jZQogICAgICAgICAgICBtZXNzYWdlKE1l" + + "c3NhZ2VQYXJhbWV0ZXJzIHsKICAgICAgICAgICAgICAgIGJvdW5jZSwKICAgICAgICAgICAgICAgIHRvLAogICAgICAgICAgICAgICAgdmFsdWU6IDAsCiAgICAgICAg" + + "ICAgICAgICBtb2RlOiBTZW5kUmVtYWluaW5nVmFsdWUgfCBTZW5kSWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgfSk7CiAgICAg" + + "ICAgICAgIHJldHVybjsKICAgICAgICB9CgogICAgICAgIC8vIExvY2sgc3RvcmFnZSBpZiBuZWVkZWQKICAgICAgICBpZiAoc2VsZi5zdG9yYWdlUmVzZXJ2ZSA+IDAp" + + "IHsgLy8gT3B0aW1pemVkIGluIGNvbXBpbGUtdGltZQogICAgICAgICAgICBsZXQgY3R4OiBDb250ZXh0ID0gY29udGV4dCgpOwogICAgICAgICAgICBsZXQgYmFsYW5j" + + "ZTogSW50ID0gbXlCYWxhbmNlKCk7CiAgICAgICAgICAgIGxldCBiYWxhbmNlQmVmb3JlTWVzc2FnZTogSW50ID0gYmFsYW5jZSAtIGN0eC52YWx1ZTsKICAgICAgICAg" + + "ICAgaWYgKGJhbGFuY2VCZWZvcmVNZXNzYWdlIDwgc2VsZi5zdG9yYWdlUmVzZXJ2ZSkgewogICAgICAgICAgICAgICAgbmF0aXZlUmVzZXJ2ZShzZWxmLnN0b3JhZ2VS" + + "ZXNlcnZlLCBSZXNlcnZlRXhhY3QpOwogICAgICAgICAgICAgICAgc2VuZChTZW5kUGFyYW1ldGVycyB7CiAgICAgICAgICAgICAgICAgICAgdG8sCiAgICAgICAgICAg" + + "ICAgICAgICAgbW9kZTogU2VuZFJlbWFpbmluZ0JhbGFuY2UgfCBTZW5kSWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgIGJvZHksCiAgICAgICAgICAgICAg" + + "ICAgICAgdmFsdWU6IDAsCiAgICAgICAgICAgICAgICAgICAgYm91bmNlLAogICAgICAgICAgICAgICAgICAgIGNvZGU6IGluaXQhIS5jb2RlLAogICAgICAgICAgICAg" + + "ICAgICAgIGRhdGE6IGluaXQhIS5kYXRhLAogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICB9Cgog" + + "ICAgICAgIC8vIEp1c3Qgc2VuZCB3aXRoIHJlbWFpbmluZyBiYWxhbmNlCiAgICAgICAgc2VuZChTZW5kUGFyYW1ldGVycyB7CiAgICAgICAgICAgIGJvdW5jZSwKICAg" + + "ICAgICAgICAgdG8sCiAgICAgICAgICAgIHZhbHVlOiAwLAogICAgICAgICAgICBtb2RlOiBTZW5kUmVtYWluaW5nVmFsdWUgfCBTZW5kSWdub3JlRXJyb3JzLAogICAg" + + "ICAgICAgICBib2R5LAogICAgICAgICAgICBjb2RlOiBpbml0ISEuY29kZSwKICAgICAgICAgICAgZGF0YTogaW5pdCEhLmRhdGEsCiAgICAgICAgfSk7CiAgICB9Cn0K"; files["std/internal/cells.tact"] = "Ly8KLy8gQnVpbGRlcgovLwoKLy8vIENyZWF0ZXMgYSBuZXcgZW1wdHkgYEJ1aWxkZXJgLgovLy8KLy8vIGBgYHRhY3QKLy8vIGZ1biBleGFtcGxlKCkgewovLy8gICAg" + "IGxldCBiOiBCdWlsZGVyID0gYmVnaW5DZWxsKCk7Ci8vLyB9Ci8vLyBgYGAKLy8vCi8vLyBTZWU6IGh0dHBzOi8vZG9jcy50YWN0LWxhbmcub3JnL3JlZi9jb3JlLWNl" + @@ -1034,209 +1027,217 @@ files["std/internal/context.tact"] = "ICAgICAgLy8gdGhpcyBpbnN0cnVjdGlvbiBlZmZlY3RpdmVseSBtdWx0aXBsaWVzIHRoZSBmd2RfZmVlIGJ5IDEuNSwKICAgICAgICAgICAgICAgICAgICAgIC8vIGF0" + "IGxlYXN0IGZvciB0aGUgY3VycmVudCB2YWx1ZSBvZiBmaXJzdF9mcmFjLCB3aGljaCBpcyAyMTg0NQp9Cg=="; files["std/internal/contract.tact"] = - "Ly8vIEdsb2JhbCBmdW5jdGlvbi4gQXZhaWxhYmxlIHNpbmNlIFRhY3QgMS42LjAuCi8vLwovLy8gQ29tcHV0ZXMgYW5kIHJldHVybnMgYW4gYEludGAgdmFsdWUgb2Yg" + - "dGhlIFNIQS0yNTYgaGFzaCBvZiB0aGUgYGNvZGVgIGFuZCBgZGF0YWAgb2YgdGhlIGdpdmVuIGNvbnRyYWN0LiBUbyBhc3NlbWJsZSB0aGUgYGNvZGVgIGFuZCBgZGF0" + - "YWAgY2VsbHMgdG9nZXRoZXIgZm9yIGhhc2hpbmcsIHRoZSBzdGFuZGFyZCBgQ2VsbGAgcmVwcmVzZW50YXRpb24gaXMgdXNlZC4KLy8vCi8vLyBUaGlzIGhhc2ggaXMg" + - "Y29tbW9ubHkgY2Fsb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yB0byB0aGUgaHR0cHM6Ly9kb2NzLnRhY3QtbGFuZy5vcmcvYm9vay9jZWxscyNjZWxscy1yZXByZXNlbnRhdGlv" + - "biwKICAgIC8vIHRoZSBsYXlvdXQgZm9yIHRoZSBCdWlsZGVyIHRvIGhhc2ggZ29lcyBhcyBmb2xsb3dzOgogICAgLy8gMSkgcmVmc19kZXNjcmlwdG9yOmJpdHM4IHwg" + - "Yml0c19kZXNjcmlwdG9yOmJpdHM4IHwgZGF0YTpiaXRzTgogICAgLy8KICAgIC8vICByZWZzX2Rlc2NyaXB0b3I6IHJlZl9jb3VudCArICgoZXhvdGljPyAmIDEpICog" + - "OCkgKyAobWFzayAqIDMyKQogICAgLy8gICAgICAgICAgICAgICAgICAgMiByZWZzIChjb2RlICsgZGF0YSksIG5vbi1leG90aWMsIHplcm8tbWFzawogICAgLy8KICAg" + - "IC8vICBiaXRzX2Rlc2NyaXB0b3I6IGZsb29yKGJpdF9jb3VudCAvIDgpICsgY2VpbChiaXRfY291bnQsIDgpCiAgICAvLyAgICAgICAgICAgICAgICAgICBmbG9vciAo" + - "NSBiaXRzIC8gOCkgKyBjZWlsKDUgYml0cyAvIDgpID0gMCArIDEgPSAxCiAgICAvLwogICAgLy8gIGRhdGE6IFswYjAwMTEwXSArIFswYjEwMF0gPSBbMGIwMDExMDEw" + - "MF0gPSAweDM0IChkYXRhICsgYXVnbWVudGVkIGJpdHMpCiAgICAvLyAgICAgICAgMGIwMDExMCAtIGRhdGEgKHNwbGl0X2RlcHRoLCBzcGVjaWFsLCBjb2RlLCBkYXRh" + - "LCBMaWJyYXJ5KQogICAgLy8gICAgICAgIDBiMTAwIC0gYXVnbWVudGVkIGJpdHMgKExlYWRpbmcgMSArIHplcm9lcyB0byBtYWtlIHNlY3Rpb24gbXVsdGlwbGUgb2Yg" + - "ZWlnaHQpCiAgICAvLwogICAgLy8gIFRoYXQgaXM6ICgyIDw8IDE2KSB8ICgxIDw8IDgpIHwgMHgzNCA9IDEzMTM4MCB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ljb2RlCi8vLwphc20gZnVuIG15Q29kZSgpOiBDZWxsIHsgTVlDT0RFIH0K"; files["std/internal/crypto.tact"] = "Ly8vIEV4dGVuc2lvbiBmdW5jdGlvbiBmb3IgdGhlIGBDZWxsYCB0eXBlLgovLy8KLy8vIENhbGN1bGF0ZXMgYW5kIHJldHVybnMgYW4gYEludGAgdmFsdWUgb2YgdGhl" + "IFtTSEEtMjU2XSBoYXNoIG9mIHRoZQovLy8gW3N0YW5kYXJkIGBDZWxsYCByZXByZXNlbnRhdGlvbl1bc3RkLXJlcHJlc2VudGF0aW9uXSBvZiB0aGUgZ2l2ZW4gYENl" + @@ -1425,181 +1426,181 @@ files["std/internal/exit-codes.tact"] = "c2VjaGFpbiAoY2hhaW4gSUQgMCkuCi8vLwovLy8gU2VlOiBodHRwczovL2RvY3MudGFjdC1sYW5nLm9yZy9ib29rL2V4aXQtY29kZXMjMTM4Ci8vLwpjb25zdCBUYWN0" + "RXhpdENvZGVOb3RCYXNlY2hhaW5BZGRyZXNzOiBJbnQgPSAxMzg7Cg=="; files["std/internal/math.tact"] = - "Ly8gUHJlcGFyZSByYW5kb20KCi8vLyBHbG9iYWwgZnVuY3Rpb24uCi8vLwovLy8gUmFuZG9taXplcyB0aGUgcHNldWRvcmFuZG9tIG51bWJlciBnZW5lcmF0b3Igd2l0" + - "aCB0aGUgc3BlY2lmaWVkIHVuc2lnbmVkIDI1Ni1iaXQgYEludGAgYHhgIGJ5IG1peGluZyBpdCB3aXRoIHRoZSBjdXJyZW50IHNlZWQuIFRoZSBuZXcgc2VlZCBpcyB0" + - "aGUgdW5zaWduZWQgMjU2LWJpdCBgSW50YCB2YWx1ZSBvZiB0aGUgU0hBLTI1NiBoYXNoIG9mIGNvbmNhdGVuYXRlZCBvbGQgc2VlZCBhbmQgYHhgIGluIHRoZWlyIDMy" + - "LWJ5dGUgc3RyaW5ncyBiaWctZW5kaWFuIHJlcHJlc2VudGF0aW9uLgovLy8KLy8vIGBgYHRhY3QKLy8vI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dmFs" + + "dWUgb2YgYG51bWAuCi8vLwovLy8gU2VlOiBodHRwczovL2RvY3MudGFjdC1sYW5nLm9yZy9yZWYvY29yZS1tYXRoI3NxcnQKLy8vCi8vLyBbSW50ZWdlciBvdXQgb2Yg" + + "ZXhwZWN0ZWQgcmFuZ2VdOiBodHRwczovL2RvY3MudGFjdC1sYW5nLm9yZy9ib29rL2V4aXQtY29kZXMjNQovLy8KZnVuIHNxcnQobnVtOiBJbnQpOiBJbnQgewogICAg" + + "aWYgKG51bSA9PSAwKSB7CiAgICAgICAgcmV0dXJuIDA7CiAgICB9CgogICAgbGV0IHM6IEludCA9IGxvZzIobnVtKTsKICAgIGxldCB4OiBJbnQgPSAocyA9PSAxID8g" + + "KG51bSAtIDEpIC8gMiArIDEgOiAxIDw8ICgocyArIDEpIC8gMikpOwoKICAgIGxldCBxOiBJbnQgPSAwOwoKICAgIGRvIHsKICAgICAgICBxID0gKGRpdmMobnVtLCB4" + + "KSAtIHgpIC8gMjsKICAgICAgICB4ICs9IHE7CiAgICB9IHVudGlsIChxID09IDApOwoKICAgIHJldHVybiB4Owp9Cg=="; files["std/internal/primitives.tact"] = "Ly8vIGBJbnRgIGlzIHRoZSBwcmltaXRpdmUgMjU3LWJpdCBzaWduZWQgaW50ZWdlciB0eXBlLgovLy8KLy8vIFNlZTogaHR0cHM6Ly9kb2NzLnRhY3QtbGFuZy5vcmcv" + "Ym9vay9pbnRlZ2VycwovLy8KcHJpbWl0aXZlIEludDsKCi8vLyBgQm9vbGAgaXMgdGhlIGNsYXNzaWNhbCBib29sZWFuIHR5cGUsIHdoaWNoIGNhbiBob2xkIG9ubHkg" + @@ -1683,412 +1684,413 @@ files["std/internal/reserve.tact"] = "YWN0LWxhbmcub3JnL3JlZi9jb3JlLWNvbnRleHRzdGF0ZSNuYXRpdmVyZXNlcnZlLW9wdGlvbmFsLWZsYWdzCi8vLwpjb25zdCBSZXNlcnZlQm91bmNlSWZBY3Rpb25G" + "YWlsOiBJbnQgPSA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kVXQwogICAgYnswMX0gU1RTTElDRUNPTlNUICAvLyBzdG9yZSB0YWcgPSAkMCBhbmQgaWhyX2Rp" + - "c2FibGVkID0gdHJ1ZQogICAgMSBTVEkgICAgICAgICAgICAgICAvLyBzdG9yZSBgYm91bmNlYAogICAgYnswMDB9IFNUU0xJQ0VDT05TVCAvLyBzdG9yZSBib3VuY2Vk" + - "ID0gZmFsc2UgYW5kIHNyYyA9IGFkZHJfbm9uZQogICAgU1RTTElDRSAgICAgICAgICAgICAvLyBzdG9yZSBgdG9gCiAgICBTV0FQCiAgICBTVEdSQU1TICAgICAgICAg" + - "ICAgIC8vIHN0b3JlIGB2YWx1ZWAKICAgIDEwNSBQVVNISU5UICAgICAgICAgLy8gMSArIDQgKyA0ICsgNjQgKyAzMgogICAgU1RaRVJPRVMgICAgICAgICAgICAvLyBz" + - "dG9yZSBjdXJyZW5jeV9jb2xsZWN0aW9uLCBpaHJfZmVlLCBmd2RfZmVlLCBjcmVhdGVkX2x0IGFuZCBjcmVhdGVkX2F0CiAgICAvLyDihpIgU3RhY2sgc3RhdGUKICAg" + - "IC8vIHMwOiBCdWlsZGVyCiAgICAvLyBzMTogYGRhdGFgCiAgICAvLyBzMjogYGNvZGVgCiAgICAvLyBzMzogYGJvZHlgCiAgICAvLyBzNDogYG1vZGVgCgogICAgLy8g" + - "R3JvdXAgMjogUGxhY2luZyB0aGUgQnVpbGRlciBhZnRlciBjb2RlIGFuZCBkYXRhLCB0aGVuIGNoZWNraW5nIHRob3NlIGZvciBudWxsYWJpbGl0eQogICAgczIgWENI" + - "RzAKICAgIERVUDIKICAgIElTTlVMTAogICAgU1dBUAogICAgSVNOVUxMCiAgICBBTkQKICAgIC8vIOKGkiBTdGFjayBzdGF0ZQogICAgLy8gczA6IC0xICh0cnVlKSBp" + - "ZiBgZGF0YWAgYW5kIGBjb2RlYCBhcmUgYm90aCBudWxsLCAwIChmYWxzZSkgb3RoZXJ3aXNlCiAgICAvLyBzMTogYGNvZGVgCiAgIC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IHM1OiBgbW9kZWAKCiAgICAvLyBHcm91cCAzOiBMZWZ0IGJyYW5j" + + "aCBvZiB0aGUgSUZFTFNFLCBleGVjdXRlZCBpZiBzMCBpcyAtMSAodHJ1ZSkKICAgIDx7CiAgICAgICAgRFJPUDIgLy8gZHJvcCBgZGF0YWAgYW5kIGBjb2RlYCwgc2lu" + + "Y2UgZWl0aGVyIG9mIHRob3NlIGlzIG51bGwKICAgICAgICBiezB9IFNUU0xJQ0VDT05TVAogICAgfT4gUFVTSENPTlQKCiAgICAvLyBHcm91cCAzOiBSaWdodCBicmFu" + + "Y2ggb2YgdGhlIElGRUxTRSwgZXhlY3V0ZWQgaWYgczAgaXMgMCAoZmFsc2UpCiAgICA8ewogICAgICAgIC8vIF8gc3BsaXRfZGVwdGg6KE1heWJlICgjIyA1KSkKICAg" + + "ICAgICAvLyAgIHNwZWNpYWw6KE1heWJlIFRpY2tUb2NrKQogICAgICAgIC8vICAgY29kZTooTWF5YmUgXkNlbGwpCiAgICAgICAgLy8gICBkYXRhOihNYXliZSBeQ2Vs" + + "bCkKICAgICAgICAvLyAgIGxpYnJhcnk6KE1heWJlIF5DZWxsKQogICAgICAgIC8vID0gU3RhdGVJbml0OwogICAgICAgIFJPVCAgICAgICAgICAgICAgICAvLyBwbGFj" + + "ZSBtZXNzYWdlIEJ1aWxkZXIgb24gdG9wCiAgICAgICAgYnsxMH0gU1RTTElDRUNPTlNUIC8vIHN0b3JlIE1heWJlID0gdHJ1ZSwgRWl0aGVyID0gZmFsc2UKICAgICAg" + + "ICAvLyBTdGFydCBjb21wb3NpbmcgaW5saW5lZCBTdGF0ZUluaXQKICAgICAgICBiezAwfSBTVFNMSUNFQ09OU1QgLy8gc3RvcmUgc3BsaXRfZGVwdGggYW5kIHNwZWNp" + + "YWwgZmlyc3QKICAgICAgICBTVERJQ1QgICAgICAgICAgICAgLy8gc3RvcmUgY29kZQogICAgICAgIFNURElDVCAgICAgICAgICAgICAvLyBzdG9yZSBkYXRhCiAgIC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lIGBJbnRgIHR5cGUuCi8vLwov" + + "Ly8gUmV0dXJucyBhIGBTdHJpbmdgIGZyb20gYW4gYEludGAgdmFsdWUuCi8vLwovLy8gTk9URTogKipHYXMgZXhwZW5zaXZlISoqIFRoaXMgZnVuY3Rpb24gdXNlcyA1" + + "MDAgZ2FzIHVuaXRzIG9yIG1vcmUuCi8vLwovLy8gYGBgdGFjdAovLy8gZnVuIGV4YW1wbGUoKSB7Ci8vLyAgICAgbGV0IGZpeno6IFN0cmluZyA9ICg4NCAtIDQyKS50" + + "b1N0cmluZygpOwovLy8gfQovLy8gYGBgCi8vLwovLy8gU2VlOiBodHRwczovL2RvY3MudGFjdC1sYW5nLm9yZy9yZWYvY29yZS1zdHJpbmdzI2ludHRvc3RyaW5nCi8v" + + "Lwphc20gZXh0ZW5kcyBmdW4gdG9TdHJpbmcoc2VsZjogSW50KTogU3RyaW5nIHsKICAgIC8vIHgKCiAgICA8ewogICAgICAgIC8vIHgKICAgICAgICBORVdDIC8vIHgg" + + "YgogICAgICAgIE9WRVIgLy8geCBiIHgKICAgICAgICAwIExFU1NJTlQgLy8geCBiIDwwPwogICAgICAgIDx7CiAgICAgICAgICAgIC8vIHggYgogICAgICAgICAgICA0" + + "NSBQVVNISU5UIC8vIHggYiA0NQogICAgICAgICAgICBTV0FQIC8vIHggNDUgYgogICAgICAgICAgICA4IFNUVSAvLyB4IGIKICAgICAgICAgICAgU1dBUCAvLyBiIHgK" + + "ICAgICAgICAgICAgTkVHQVRFIC8vIGIgLXgKICAgICAgICAgICAgU1dBUCAvLyAteCBiCiAgICAgICAgfT5DT05UIElGCiAgICAgICAgLy8geCBiCgogICAgICAgIFNX" + + "QVAgLy8gYiB4CgogICAgICAgIDx7CiAgICAgICAgICAgIC8vIGIgeAogICAgICAgICAgICAxMCBQVVNISU5UIERJVk1PRCAvLyBiIHgvMTAgeCUxMAogICAgICAgICAg" + + "ICA0OCBBRERDT05TVCAvLyBiIHgvMTAgKHglMTArNDgpCiAgICAgIC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U2VlOiBodHRwczovL2RvY3MudGFjdC1sYW5n" + - "Lm9yZy9yZWYvY29yZS1zdHJpbmdzI2ludHRvc3RyaW5nCi8vLwphc20gZXh0ZW5kcyBmdW4gdG9TdHJpbmcoc2VsZjogSW50KTogU3RyaW5nIHsKICAgIC8vIHgKCiAg" + - "ICA8ewogICAgICAgIC8vIHgKICAgICAgICBORVdDIC8vIHggYgogICAgICAgIE9WRVIgLy8geCBiIHgKICAgICAgICAwIExFU1NJTlQgLy8geCBiIDwwPwogICAgICAg" + - "IDx7CiAgICAgICAgICAgIC8vIHggYgogICAgICAgICAgICA0NSBQVVNISU5UIC8vIHggYiA0NQogICAgICAgICAgICBTV0FQIC8vIHggNDUgYgogICAgICAgICAgICA4" + - "IFNUVSAvLyB4IGIKICAgICAgICAgICAgU1dBUCAvLyBiIHgKICAgICAgICAgICAgTkVHQVRFIC8vIGIgLXgKICAgICAgICAgICAgU1dBUCAvLyAteCBiCiAgICAgICAg" + - "fT5DT05UIElGCiAgICAgICAgLy8geCBiCgogICAgICAgIFNXQVAgLy8gYiB4CgogICAgICAgIDx7CiAgICAgICAgICAgIC8vIGIgeAogICAgICAgICAgICAxMCBQVVNI" + - "SU5UIERJVk1PRCAvLyBiIHgvMTAgeCUxMAogICAgICAgICAgICA0OCBBRERDT05TVCAvLyBiIHgvMTAgKHglMTArNDgpCiAgICAgICAgICAgIHMyIHMyIHMwIFhDMlBV" + - "IElTWkVSTyAvLyAoeCUxMCs0OCkgYiB4LzEwIHgvMTA9PTA/CiAgICAgICAgfT5DT05UIFVOVElMCiAgICAgICAgLy8gLi4uIGIgeAoKICAgICAgICBEUk9QIC8vIC4u" + - "LiBiCiAgICAgICAgREVQVEggREVDIC8vIC4uLiBiIG4KICAgICAgICA8eyA4IFNUVSB9PkNPTlQgUkVQRUFUIC8vIGIKICAgIH0+Q09OVCAxIDEgQ0FMTFhBUkdTCiAg" + - "ICAvLyBiCgogICAgRU5EQyBDVE9TIC8vIHMKfQoKLy8vIEV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ESVZNT0QgLy8gYiBkaWdpdHMgbGVmdCByaWdodAogICAgczMgczMg" + - "WENIRzIgLy8gcmlnaHQgZGlnaXRzIGIgbGVmdAoKICAgIDx7CiAgICAgICAgLy8gYiB4CgogICAgICAgIDx7CiAgICAgICAgICAgIC8vIGIgeAogICAgICAgICAgICAx" + - "MCBQVVNISU5UIERJVk1PRCAvLyBiIHgvMTAgeCUxMAogICAgICAgICAgICA0OCBBRERDT05TVCAvLyBiIHgvMTAgKHglMTArNDgpCiAgICAgICAgICAgIHMyIHMyIHMw" + - "IFhDMlBVIElTWkVSTyAvLyAoeCUxMCs0OCkgYiB4LzEwIHgvMTA9PTA/CiAgICAgICAgfT5DT05UIFVOVElMCiAgICAgICAgLy8gLi4uIGIgeAoKICAgICAgICBEUk9Q" + - "IC8vIC4uLiBiCiAgICAgICAgREVQVEggREVDIC8vIC4uLiBiIG4KICAgICAgICA8eyA4IFNUVSB9PkNPTlQgUkVQRUFUIC8vIGIKICAgIH0+Q09OVCAyIDEgQ0FMTFhB" + - "UkdTCgogICAgLy8gcmlnaHQgZGlnaXRzICJsZWZ0IgoKICAgIFJPVCAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0CiAgICBEVVAgLy8gZGlnaXRzICJsZWZ0IiByaWdodCBy" + - "aWdodAogICAgSVNaRVJPIC8vIGRpZ2l0cyAibGVmdCIgcmlnaHQgcmlnaHQ9PTA/CgogICAgPHsKICAgICAgICAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0CiAgICAgICAg" + - "RFJPUCAvLyBkaWdpdHMgImxlZnQiCiAgICAgICAgTklQIC8vICJsZWZ0IgogICAgfT5DT05UCgogICAgPHsKICAgICAgICAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0CiAg" + - "ICAgICAgWkVSTyAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0IDAKICAgICAgICBTV0FQIC8vIGRpZ2l0cyAibGVmdCIgMCByaWdodAoKICAgICAgICA8ewogICAgICAgICAg" + - "ICAvLyBkaWdpdHMgImxlZnQiIGkgcmlnaHQKICAgICAgICAgICAgRFVQIC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodCByaWdodAogICAgICAgICAgICAxMCBQVVNISU5U" + - "IC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodCByaWdodCAxMAogICAgICAgICAgICBNT0QgLy8gZGlnaXRzICJsZWZ0IiBpIHJpZ2h0IHJpZ2h0JTEwCiAgICAgICAgICAg" + - "IElTWkVSTyAvLyBkaWdpdHMgImxlZnQiIGkgcmlnaHQgcmlnaHQlMTA9PTA/CiAgICAgICAgfT5DT05UCgogICAgICAgIDx7CiAgICAgICAgICAgIC8vIGRpZ2l0cyAi" + - "bGVmdCIgaSByaWdodAogICAgICAgICAgICAxMCBQVVNISU5UIC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodCAxMAogICAgICAgICAgICBESVYgLy8gZGlnaXRzICJsZWZ0" + - "IiBpIHJpZ2h0LzEwCiAgICAgICAgICAgIFNXQVAgLy8gZGlnaXRzICJsZWZ0IiByaWdodC8xMCBpCiAgICAgICAgICAgIElOQyAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0" + - "LzEwIGkrMQogICAgICAgICAgICBTV0FQIC8vIGRpZ2l0cyAibGVmdCIgaSsxIHJpZ2h0LzEwCiAgICAgICAgfT5DT05UCgogICAgICAgIFdISUxFIC8vIGRpZ2l0cyAi" + - "bGVmdCIgaSByaWdodAoKICAgICAgICA8ewogICAgICAgICAgICAvLyB4CiAgICAgICAgICAgIE5FV0MgLy8geCBiCiAgICAgICAgICAgIFNXQVAgLy8gYiB4CgogICAg" + - "ICAgICAgICA8ewogICAgICAgICAgICAgICAgLy8gYiB4CiAgICAgICAgICAgICAgICAxMCBQVVNISU5UIERJVk1PRCAvLyBiIHgvMTAgeCUxMAogICAgICAgICAgICAg" + - "ICAgNDggQUREQ09OU1QgLy8gYiB4LzEwICh4JTEwKzQ4KQogICAgICAgICAgICAgICAgczIgczIgczAgWEMyUFUgSVNaRVJPIC8vICh4JTEwKzQ4KSBiIHgvMTAgeC8x" + - "MD09MD8KICAgICAgICAgICAgfT5DT05UIFVOVElMCiAgICAgICAgICAgIC8vIC4uLiBiIHgKCiAgICAgICAgICAgIERST1AgLy8gLi4uIGIKICAgICAgICAgICAgREVQ" + - "VEggREVDIERVUCAvLyAuLi4gYiBuIG4KICAgICAgICAgICAgUk9UUkVWIC8vIC4uLiBuIGIgbgogICAgICAgICAgICA8ewogICAgICAgICAgICAgICAgLy8gLi4uIGMg" + - "biBiCiAgICAgICAgICAgICAgICBzMSBzMiBYQ0hHIC8vIC4uLiBuIGMgYgogICAgICAgICAgICAgICAgOCBTVFUgLy8gLi4uIG4gYgogICAgICAgICAgICB9PkNPTlQg" + - "UkVQRUFUIC8vIG4gYgogICAgICAgIH0+Q09OVCAxIDIgQ0FMTFhBUkdTCiAgICAgICAgLy8gZGlnaXRzICJsZWZ0IiBpIHJpZ2h0X2RpZ2l0cyAicmlnaHQiCiAgICAg" + - "ICAgUk9UUkVWIC8vIGRpZ2l0cyAibGVmdCIgInJpZ2h0IiBpIHJpZ2h0X2RpZ2l0cwogICAgICAgIEFERCAvLyBkaWdpdHMgImxlZnQiICJyaWdodCIgcmlnaHRfZGln" + - "aXRzCgogICAgICAgIHMzIHMxIFhDSEcgLy8gInJpZ2h0IiAibGVmdCIgZGlnaXRzIHJpZ2h0X2RpZ2l0cwogICAgICAgIFNVQiAvLyAicmlnaHQiICJsZWZ0IiBkaWdp" + - "dHNfZGlmZgogICAgICAgIFNXQVAgLy8gInJpZ2h0IiBkaWdpdHNfZGlmZiAibGVmdCIKICAgICAgICB4ezJlfSBTVFNMSUNFQ09OU1QgLy8gInJpZ2h0IiBkaWdpdHNf" + - "ZGlmZiAibGVmdC4iCiAgICAgICAgU1dBUCAvLyAicmlnaHQiICJsZWZ0LiIgZGlnaXRzX2RpZmYKCiAgICAgICAgPHsKICAgICAgICAgICAgLy8gInJpZ2h0IiAibGVm" + - "dC4iCiAgICAgICA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iIHgvMTAgeCUxMAogICAg" + + "ICAgICAgICA0OCBBRERDT05TVCAvLyBiIHgvMTAgKHglMTArNDgpCiAgICAgICAgICAgIHMyIHMyIHMwIFhDMlBVIElTWkVSTyAvLyAoeCUxMCs0OCkgYiB4LzEwIHgv" + + "MTA9PTA/CiAgICAgICAgfT5DT05UIFVOVElMCiAgICAgICAgLy8gLi4uIGIgeAoKICAgICAgICBEUk9QIC8vIC4uLiBiCiAgICAgICAgREVQVEggREVDIC8vIC4uLiBi" + + "IG4KICAgICAgICA8eyA4IFNUVSB9PkNPTlQgUkVQRUFUIC8vIGIKICAgIH0+Q09OVCAyIDEgQ0FMTFhBUkdTCgogICAgLy8gcmlnaHQgZGlnaXRzICJsZWZ0IgoKICAg" + + "IFJPVCAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0CiAgICBEVVAgLy8gZGlnaXRzICJsZWZ0IiByaWdodCByaWdodAogICAgSVNaRVJPIC8vIGRpZ2l0cyAibGVmdCIgcmln" + + "aHQgcmlnaHQ9PTA/CgogICAgPHsKICAgICAgICAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0CiAgICAgICAgRFJPUCAvLyBkaWdpdHMgImxlZnQiCiAgICAgICAgTklQIC8v" + + "ICJsZWZ0IgogICAgfT5DT05UCgogICAgPHsKICAgICAgICAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0CiAgICAgICAgWkVSTyAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0IDAK" + + "ICAgICAgICBTV0FQIC8vIGRpZ2l0cyAibGVmdCIgMCByaWdodAoKICAgICAgICA8ewogICAgICAgICAgICAvLyBkaWdpdHMgImxlZnQiIGkgcmlnaHQKICAgICAgICAg" + + "ICAgRFVQIC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodCByaWdodAogICAgICAgICAgICAxMCBQVVNISU5UIC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodCByaWdodCAxMAog" + + "ICAgICAgICAgICBNT0QgLy8gZGlnaXRzICJsZWZ0IiBpIHJpZ2h0IHJpZ2h0JTEwCiAgICAgICAgICAgIElTWkVSTyAvLyBkaWdpdHMgImxlZnQiIGkgcmlnaHQgcmln" + + "aHQlMTA9PTA/CiAgICAgICAgfT5DT05UCgogICAgICAgIDx7CiAgICAgICAgICAgIC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodAogICAgICAgICAgICAxMCBQVVNISU5U" + + "IC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodCAxMAogICAgICAgICAgICBESVYgLy8gZGlnaXRzICJsZWZ0IiBpIHJpZ2h0LzEwCiAgICAgICAgICAgIFNXQVAgLy8gZGln" + + "aXRzICJsZWZ0IiByaWdodC8xMCBpCiAgICAgICAgICAgIElOQyAvLyBkaWdpdHMgImxlZnQiIHJpZ2h0LzEwIGkrMQogICAgICAgICAgICBTV0FQIC8vIGRpZ2l0cyAi" + + "bGVmdCIgaSsxIHJpZ2h0LzEwCiAgICAgICAgfT5DT05UCgogICAgICAgIFdISUxFIC8vIGRpZ2l0cyAibGVmdCIgaSByaWdodAoKICAgICAgICA8ewogICAgICAgICAg" + + "ICAvLyB4CiAgICAgICAgICAgIE5FV0MgLy8geCBiCiAgICAgICAgICAgIFNXQVAgLy8gYiB4CgogICAgICAgICAgICA8ewogICAgICAgICAgICAgICAgLy8gYiB4CiAg" + + "ICAgICAgICAgICAgICAxMCBQVVNISU5UIERJVk1PRCAvLyBiIHgvMTAgeCUxMAogICAgICAgICAgICAgICAgNDggQUREQ09OU1QgLy8gYiB4LzEwICh4JTEwKzQ4KQog" + + "ICAgICAgICAgICAgICAgczIgczIgczAgWEMyUFUgSVNaRVJPIC8vICh4JTEwKzQ4KSBiIHgvMTAgeC8xMD09MD8KICAgICAgICAgICAgfT5DT05UIFVOVElMCiAgICAg" + + "ICAgICAgIC8vIC4uLiBiIHgKCiAgICAgICAgICAgIERST1AgLy8gLi4uIGIKICAgICAgICAgICAgREVQVEggREVDIERVUCAvLyAuLi4gYiBuIG4KICAgICAgICAgICA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nCi8vLwpAbmFtZShfX3RhY3RfYWRkcmVzc190b191c2VyX2ZyaWVuZGx5KQpleHRlbmRzIG5hdGl2ZSB0b1N0cmluZyhzZWxmOiBBZGRyZXNz" + + "KTogU3RyaW5nOwo="; files["std/internal/time.tact"] = "Ly8vIEdsb2JhbCBmdW5jdGlvbi4KLy8vCi8vLyBSZXR1cm5zIHRoZSBjdXJyZW50IFVuaXggdGltZS4KLy8vCi8vLyBgYGB0YWN0Ci8vLyBmdW4gZXhhbXBsZSgpIHsK" + "Ly8vICAgICBsZXQgdGltZU9mZnNldDogSW50ID0gbm93KCkgKyAxMDAwOyAvLyB0aG91c2FuZCBzZWNvbmRzIGZyb20gbm93KCkKLy8vIH0KLy8vIGBgYAovLy8KLy8v" + diff --git a/src/stdlib/stdlib/std/internal/address.tact b/src/stdlib/stdlib/std/internal/address.tact index 7df2aed0d9..793a17482a 100644 --- a/src/stdlib/stdlib/std/internal/address.tact +++ b/src/stdlib/stdlib/std/internal/address.tact @@ -1,3 +1,7 @@ +import "./debug"; +import "./cells"; +import "./exit-codes"; + /// Extension function for the `Slice` type. Available since Tact 1.6.0. /// /// Casts the `Slice` to an `Address` in a given `chain` ID and returns it. The inverse of `Address.asSlice()` and a safe but more gas-expensive version of `Slice.asAddressUnsafe()`. @@ -315,26 +319,6 @@ inline fun newBasechainAddress(hash: Int): BasechainAddress { return BasechainAddress { hash }; } -/// Global function. Available since Tact 1.6.0. -/// -/// Creates and returns a basechain address derived from a contract's `StateInit` (code and data). -/// -/// ```tact -/// fun example() { -/// let code: Cell = loadCell(); // load contract code -/// let data: Cell = loadCell(); // load contract data -/// let state: StateInit = StateInit { code, data }; -/// let addr: BasechainAddress = contractBasechainAddress(state); -/// } -/// ``` -/// -/// See: https://docs.tact-lang.org/ref/core-addresses#contractbasechainaddress -/// -inline fun contractBasechainAddress(s: StateInit): BasechainAddress { - let hash = contractHash(s.code, s.data); - return newBasechainAddress(hash); -} - /// Extension function for the `Builder` type. Available since Tact 1.6.0. /// /// Stores the basechain address in the copy of the Builder and returns that copy. diff --git a/src/stdlib/stdlib/std/internal/base.tact b/src/stdlib/stdlib/std/internal/base.tact index 4454446b3f..dd77eb39bf 100644 --- a/src/stdlib/stdlib/std/internal/base.tact +++ b/src/stdlib/stdlib/std/internal/base.tact @@ -1,3 +1,8 @@ +import "./context"; +import "./contract"; +import "./reserve"; +import "./send"; + /// Describes the base logic that is available in all contracts and traits by default. /// /// This trait is implicitly inherited by every other contract and trait. diff --git a/src/stdlib/stdlib/std/internal/contract.tact b/src/stdlib/stdlib/std/internal/contract.tact index 4f24460143..e7314e3473 100644 --- a/src/stdlib/stdlib/std/internal/contract.tact +++ b/src/stdlib/stdlib/std/internal/contract.tact @@ -1,3 +1,6 @@ +import "./address"; +import "./context"; + /// Global function. Available since Tact 1.6.0. /// /// Computes and returns an `Int` value of the SHA-256 hash of the `code` and `data` of the given contract. To assemble the `code` and `data` cells together for hashing, the standard `Cell` representation is used. @@ -83,17 +86,37 @@ inline fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address { return newAddress(chain, hash); } +/// Global function. Available since Tact 1.6.0. +/// +/// Creates and returns a basechain address derived from a contract's `StateInit` (code and data). +/// +/// ```tact +/// fun example() { +/// let code: Cell = loadCell(); // load contract code +/// let data: Cell = loadCell(); // load contract data +/// let state: StateInit = StateInit { code, data }; +/// let addr: BasechainAddress = contractBasechainAddress(state); +/// } +/// ``` +/// +/// See: https://docs.tact-lang.org/ref/core-addresses#contractbasechainaddress +/// +inline fun contractBasechainAddress(s: StateInit): BasechainAddress { + let hash = contractHash(s.code, s.data); + return newBasechainAddress(hash); +} + /// Struct containing the initial state, i.e. initial code and initial data of the given contract upon its deployment. /// /// See: https://docs.tact-lang.org/book/expressions#initof /// -struct StateInit { - /// Initial code of the contract (compiled bitcode) - code: Cell; +// struct StateInit { +// /// Initial code of the contract (compiled bitcode) +// code: Cell; - /// Initial data of the contract (parameters of `init()` function or contract parameters) - data: Cell; -} +// /// Initial data of the contract (parameters of `init()` function or contract parameters) +// data: Cell; +// } /// Global function. Available since Tact 1.6.1. /// diff --git a/src/stdlib/stdlib/std/internal/math.tact b/src/stdlib/stdlib/std/internal/math.tact index c124885b5d..4ecdc1356f 100644 --- a/src/stdlib/stdlib/std/internal/math.tact +++ b/src/stdlib/stdlib/std/internal/math.tact @@ -1,3 +1,5 @@ +import "./debug"; + // Prepare random /// Global function. diff --git a/src/stdlib/stdlib/std/internal/send.tact b/src/stdlib/stdlib/std/internal/send.tact index c7b783bebe..a5090d8940 100644 --- a/src/stdlib/stdlib/std/internal/send.tact +++ b/src/stdlib/stdlib/std/internal/send.tact @@ -1,3 +1,5 @@ +import "./cells"; + /// Ordinary message (default). /// /// This constant is available since Tact 1.6.0. diff --git a/src/stdlib/stdlib/std/internal/text.tact b/src/stdlib/stdlib/std/internal/text.tact index 1f1238b82d..3ff06bb589 100644 --- a/src/stdlib/stdlib/std/internal/text.tact +++ b/src/stdlib/stdlib/std/internal/text.tact @@ -1,3 +1,7 @@ +import "./cells"; +import "./exit-codes"; +import "./debug"; + // // String builder // diff --git a/src/utils/array.ts b/src/utils/array.ts index 5ab0ead8c8..9cf0dfd66e 100644 --- a/src/utils/array.ts +++ b/src/utils/array.ts @@ -1,4 +1,15 @@ -export const zip = (arr1: T[], arr2: U[]): [T, U][] => { +export const mapValues = ( + map: Map, + f: (a: A) => B, +): Map => { + const result: [K, B][] = []; + for (const [k, a] of map) { + result.push([k, f(a)]); + } + return new Map(result); +}; + +export const zip = (arr1: readonly T[], arr2: readonly U[]): [T, U][] => { const length = Math.min(arr1.length, arr2.length); return arr1.slice(0, length).flatMap((item1, index) => { const item2 = arr2[index]; diff --git a/src/utils/log-deep.build.ts b/src/utils/log-deep.build.ts new file mode 100644 index 0000000000..1182f46e9a --- /dev/null +++ b/src/utils/log-deep.build.ts @@ -0,0 +1,11 @@ +import { inspect } from "util"; + +// log json to terminal without shortening +export const logDeep = (obj: unknown, colors = true) => { + console.log( + inspect(obj, { + colors, + depth: Infinity, + }), + ); +}; diff --git a/src/utils/tricks.ts b/src/utils/tricks.ts index f50e6903b5..2445308e03 100644 --- a/src/utils/tricks.ts +++ b/src/utils/tricks.ts @@ -148,3 +148,35 @@ export const entries = Object.entries as ( ) => { [K in keyof O]: [K, O[K]] }[keyof O][]; export const keys = Object.keys as (o: O) => (keyof O)[]; + +export const memo = (f: (a: A) => B) => { + const cache: Map = new Map(); + return (a: A): B => { + const mem = cache.get(a); + if (typeof mem !== "undefined") { + return mem; + } + const b = f(a); + cache.set(a, b); + return b; + }; +}; + +export const includes = ( + keys: readonly K[], + key: string, +): key is K => { + // we have to do this, otherwise, the next line will complain that `key` isn't `K` + const keys1: readonly string[] = keys; + return keys1.includes(key); +}; + +export const hideProperty = (o: T, k: K): T => { + Object.defineProperty(o, k, { + value: o[k], + writable: true, + configurable: true, + enumerable: false, + }); + return o; +}; diff --git a/yarn.lock b/yarn.lock index 4dde884faf..1f78c9cb5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1572,6 +1572,11 @@ dependencies: undici-types "~6.21.0" +"@types/serialize-javascript@^5.0.4": + version "5.0.4" + resolved "https://npm.dev-internal.org/@types/serialize-javascript/-/serialize-javascript-5.0.4.tgz#7a7c32248e207a0d29afed88e5ee3e921999c73d" + integrity sha512-Z2R7UKFuNWCP8eoa2o9e5rkD3hmWxx/1L0CYz0k2BZzGh0PhEVMp9kfGiqEml/0IglwNERXZ2hwNzIrSz/KHTA== + "@types/stack-utils@^2.0.0": version "2.0.3" resolved "https://npm.dev-internal.org/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" @@ -4989,6 +4994,13 @@ rabin-wasm@^0.1.4: node-fetch "^2.6.1" readable-stream "^3.6.0" +randombytes@^2.1.0: + version "2.1.0" + resolved "https://npm.dev-internal.org/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + react-is@^18.0.0: version "18.3.1" resolved "https://npm.dev-internal.org/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" @@ -5135,7 +5147,7 @@ safe-array-concat@^1.1.3: has-symbols "^1.1.0" isarray "^2.0.5" -safe-buffer@~5.2.0: +safe-buffer@^5.1.0, safe-buffer@~5.2.0: version "5.2.1" resolved "https://npm.dev-internal.org/safe-buffer/-/safe-buffer-5.2.1.tgz" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -5172,6 +5184,13 @@ semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.3, semver@^7.7.2: resolved "https://npm.dev-internal.org/semver/-/semver-7.7.2.tgz#67d99fdcd35cec21e6f8b87a7fd515a33f982b58" integrity sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA== +serialize-javascript@^6.0.2: + version "6.0.2" + resolved "https://npm.dev-internal.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" + integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== + dependencies: + randombytes "^2.1.0" + set-function-length@^1.2.2: version "1.2.2" resolved "https://npm.dev-internal.org/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449"